-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.147 (from the pkg.jenkins.io/redhat repo), running on Fedora
We currently have a multi stage pipeline, where the first stage can calculate some parameters to be used when setting up the agent for the next stage (in this case, installing the build dependencies into the container). Using a variable in the pipeline doesn't work correctly - only the initial value of the variable is picked up when building the docker container.
e.g.
def builddeps="test" pipeline { agent none stages { stage('Configure') { agent { dockerfile { filename 'Dockerfile.configure' dir 'dist' } } steps { echo 'Configure..' checkout scm script { builddeps="test2" } } } stage('Build') { agent { dockerfile { filename 'Dockerfile.build' additionalBuildArgs "--build-arg BUILD_DEPS=$builddeps" dir 'dist' } } steps { echo "Build $buildargs" } } } }
I would expect the Build agent to be created with "--build-arg BUILD_DEPS=test2", but it is created with BUILD_DEPS=test"
I can work around this by writing the variable to a file, then reading the file back when creating the agent, but it doesn't feel like the correct way to do things.