Team, I want to capture a var remoteUrl
value coming from jenkinsfile into groovy library that is passed from jenkinsfile and store it in env var to access later. but I can’t seem to do it. any hint what am i missing?
def call(Map config) {
for (param in ['credentialsId', 'remoteUrl']) {
if (!config[param]) {
error "checkoutGit(): missing parameter ${param}"
}
}
env = ["REMOTE_URL=${config.remoteUrl}"]
final GIT_YX_URL = "ssh://@git-YX"
final LIB_GIT_YX_MIRROR_URL = "git://git-mirror:111/git-t"
if (config.remoteUrl) {
println "Git YX url passed in user job"
env.add("GIT_YX_MIRROR_URL=${config.remoteUrl}")
echo "GIT_YX_MIRROR_URL is: ${GIT_YX_MIRROR_URL}"
} else {
println "No Git YX url passed in user job, using Library defined Git Mirror URL"
env.add("GIT_YX_MIRROR_URL=$LIB_GIT_YX_MIRROR_URL")
}
my jenkinsfile is
def REPO_MIRROR_URL = 'git://git-mirror'
steps {
container('main') {
script {
checkoutUtil(
credentialsId: 'git-ssh',
remoteUrl: "$REPO_MIRROR_URL",
)
}
error am getting is
Git YX url passed in user job
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 01e941fa-4301-4ccc-a4ac-f286eb1e7baa
hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: GIT_YX_MIRROR_URL for class: checkoutUtil
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)