I'm using Jenkins Template Engine and I'm facing the following issue:
Let's say I want to have a library step that uploads artifacts to Artifactory. This step should set as a property the URL of the git commit. I want that each project will provide this URL in a pipeline_config.groovy
file, not hard-coded in the step.
The thing is, that this URL is composed of some fixed string, plus a dynamic value, namely env.GIT_COMMIT
: eg: http://specific-server.com/project/${env.GIT_COMMIT}
Eventually, I want the step to be as follows:
// upload.groovy
def call() {
def props = config.git_url
}
and the pipeline_config file:
// pipeline_config.groovy
libraries {
artifactory
{
git_url = "http://specific-server/project/${env.GIT_COMMIT}"
}
}
So the question comes down to this: How can I instruct the library step to retreive some dynamic variable from the pipeline_config.groovy file?
@steven-terrana
JTE can resolve the env
var within the pipeline configuration, assuming the environment has been set for the build.
If the GIT_COMMIT comes from the project being built, you could determine that information from within the library step using the git cli and then concatenate the base-url provided from the pipeline configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.