| As none of those variables provide us with something that can be configure on a slave level, this is what we did as an (ugly) workaround. We define an environment variable called REFERENCE_REPO on each slave and the master. Inside our jenkins pipeline library we create a step called checkoutCurrent
import java.util.regex.Pattern
import hudson.plugins.git.extensions.impl.CloneOption
// checkout current scm and resolve the REFERENCE_REPO environment variable, workaround for JENKINS-43894
def call(originalScm) {
if (originalScm.hasProperty('extensions') && originalScm.extensions) {
print('has extensions')
def extensions = originalScm.extensions
def updatedExtension = null
for (int i = 0; i < extensions.size(); i++) {
def extension = extensions[i]
if (extension instanceof CloneOption && extension.hasProperty('reference') && extension.reference) {
def reference = extension.reference
print('replacing reference: ' + reference)
reference = reference.replaceAll(Pattern.quote('${REFERENCE_REPO}'), env.REFERENCE_REPO)
print('with: ' + reference)
updatedExtension = new CloneOption(extension.shallow, extension.noTags, reference, extension.timeout)
}
}
if (updatedExtension) {
extensions.replace(updatedExtension)
}
}
checkout changelog: false, poll: false, scm: originalScm
}
and then in the pipeline instead of
checkout changelog: false, poll: false, scm: scm
we do
|