I have a parameterized upstream build A that should remain untouched as far as possible. Now I want to configure my downstream build B with a declarative pipeline.
So I defined in the Jekinsfile of project B in the triggers
section a upstream relation to A. But now I'm stuck with getting the build parameters of build A.
So far I came across the following Ideas:
- Using the Jenkins job API (I would only do this if there is no way to specify this directly in a Jenkinsfile)
- From my current view using the Parameterized Trigger Plugin is not a an option since I do not want to reconfigure the upstream job when another downstream job is added.
In my Jenkinsfile of job B I would like to do something like this:
pipeline {
agent docker
environment {
FOO = ""
}
triggers {
upstream(upstreamProjects: 'A', threshold: hudson.model.Result.SUCCESS)
}
stages {
stage('Print params') {
steps {
script {
// I would expect something like this to access the FOO variable of job A
// ${env.FOO} = job('A').params.FOO
}
}
}
}
}
I would like to directly access parameters of the build from job A that triggered the current build of job B.