-
Bug
-
Resolution: Fixed
-
Major
-
None
-
delivery 1.4.7
jenkins 1.616
Environment Injector Plugin 1.91.3
Update:
Here's a test case that fails. Added to PipelineVersionTokenMacroTest. I also added the two getBuildVariableResolver() lines to the testWithBuildNameSetterPlugin() test method, and they pass there.
@Test
public void testWithBuildNameSetterPluginAndAdditionalParameters() throws Exception {
FreeStyleProject a = jenkins.createFreeStyleProject("a");
FreeStyleProject b = jenkins.createFreeStyleProject("b");
a.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("BUILD_VERSION", "DEFAULT_VALUE")));
a.getPublishersList().add(new BuildTrigger("b", false));
a.getBuildWrappersList().add(new PipelineVersionContributor(true, "1.0.0.$BUILD_NUMBER"));
b.getBuildWrappersList().add(new BuildNameSetter("$PIPELINE_VERSION"));
jenkins.getInstance().rebuildDependencyGraph();
jenkins.setQuietPeriod(0);
jenkins.buildAndAssertSuccess(a);
jenkins.waitUntilNoActivity();
assertEquals("1.0.0.1", a.getLastBuild().getDisplayName());
assertEquals("1.0.0.1", b.getLastBuild().getDisplayName());
assertEquals("1.0.0.1", a.getLastBuild().getBuildVariableResolver().resolve("PIPELINE_VERSION"));
assertEquals("1.0.0.1", b.getLastBuild().getBuildVariableResolver().resolve("PIPELINE_VERSION"));
}
I get different behavior depending on if a non-pipeline parameter is defined on a Job. Here's the smallest job I could configure. Parameter type doesn't seem to matter.
<?xml version='1.0' encoding='UTF-8'?> <project> <actions/> <description></description> <keepDependencies>false</keepDependencies> <properties> <hudson.model.ParametersDefinitionProperty> <parameterDefinitions> <hudson.model.BooleanParameterDefinition> <name>A_PARAMETER</name> <description></description> <defaultValue>true</defaultValue> </hudson.model.BooleanParameterDefinition> </parameterDefinitions> </hudson.model.ParametersDefinitionProperty> </properties> <scm class="hudson.scm.NullSCM"/> <assignedNode>docker-one-slave</assignedNode> <canRoam>false</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders> <hudson.tasks.Shell> <command>echo "PIPELINE_VERSION: ${PIPELINE_VERSION}"</command> </hudson.tasks.Shell> <hudson.plugins.groovy.SystemGroovy plugin="groovy@1.25"> <scriptSource class="hudson.plugins.groovy.StringScriptSource"> <command>println "build.getEnvironment(listener)['PIPELINE_VERSION']: ${build.getEnvironment(listener)['PIPELINE_VERSION']}" println "build.buildVariableResolver.resolve('PIPELINE_VERSION'): ${build.buildVariableResolver.resolve('PIPELINE_VERSION')}" </command> </scriptSource> <bindings></bindings> <classpath></classpath> </hudson.plugins.groovy.SystemGroovy> </builders> <publishers/> <buildWrappers> <se.diabol.jenkins.pipeline.PipelineVersionContributor plugin="delivery-pipeline-plugin@0.9.3"> <versionTemplate>1.0.0.${BUILD_NUMBER}</versionTemplate> <updateDisplayName>true</updateDisplayName> </se.diabol.jenkins.pipeline.PipelineVersionContributor> </buildWrappers> </project>
If I execute the Job with no additional Parameters, I see the PIPELINE_VERSION in the Parameters page for the Job, but it's not there if there is an additional Parameter defined.
It is in the ${JOB_URL}/api/xml in both situations, and it does seem to be getting passed to downstream jobs.
PIPELINE_VERSION also doesn't seem to be available through the buildVariableResolver when an additional Parameter is defined, but is when the parameter is not defined:
No additional Parameters defined:
Creating version: 1.0.0.36
[A] $ /bin/sh -xe /tmp/hudson51864413681590712.sh
+ echo 'PIPELINE_VERSION: 1.0.0.36'
PIPELINE_VERSION: 1.0.0.36
build.getEnvironment(listener)['PIPELINE_VERSION']: 1.0.0.36
build.buildVariableResolver.resolve('PIPELINE_VERSION'): 1.0.0.36
Additional Parameter defined:
Creating version: 1.0.0.35
[A] $ /bin/sh -xe /tmp/hudson5436099757112549933.sh
+ echo 'PIPELINE_VERSION: 1.0.0.35'
PIPELINE_VERSION: 1.0.0.35
build.getEnvironment(listener)['PIPELINE_VERSION']: 1.0.0.35
build.buildVariableResolver.resolve('PIPELINE_VERSION'): null
Let me know if there's anything else I can provide/debug/diagnose/etc.
Thanks!