Details
-
Type:
Bug
-
Status: Resolved (View Workflow)
-
Priority:
Major
-
Resolution: Duplicate
-
Component/s: pipeline
-
Labels:
-
Environment:Jenkins 1.6.4.6
Workflow-cps 1.15
-
Similar Issues:
Description
On normal maven/freestyle jobs the checked out branch can be parameterized with job parameters.
The following job uses the workflow plugin to pull a groovy script from scm.
Here the ${branch} variable is not substituted.
<?xml version="1.0" encoding="UTF-8"?> <flow-definition plugin="workflow-job@1.15"> <actions /> <description>WARNING: this jobs fails due to not substituting ${branch} on ckeckout.</description> <keepDependencies>false</keepDependencies> <properties> <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin@1.7.3"> <useBuildBlocker>false</useBuildBlocker> <blockLevel>GLOBAL</blockLevel> <scanQueueFor>DISABLED</scanQueueFor> <blockingJobs /> </hudson.plugins.buildblocker.BuildBlockerProperty> <hudson.model.ParametersDefinitionProperty> <parameterDefinitions> <hudson.model.StringParameterDefinition> <name>releaseVersion</name> <description /> <defaultValue /> </hudson.model.StringParameterDefinition> <hudson.model.StringParameterDefinition> <name>branch</name> <description /> <defaultValue>6.4.x</defaultValue> </hudson.model.StringParameterDefinition> </parameterDefinitions> </hudson.model.ParametersDefinitionProperty> </properties> <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@1.15"> <scm class="hudson.plugins.git.GitSCM" plugin="git@2.4.3"> <configVersion>2</configVersion> <userRemoteConfigs> <hudson.plugins.git.UserRemoteConfig> <url>ssh://git@someSever:7999/SomeRepo.git</url> </hudson.plugins.git.UserRemoteConfig> </userRemoteConfigs> <branches> <hudson.plugins.git.BranchSpec> <name>refs/heads/${branch}</name><!-- THIS should be substituted but isn't --> </hudson.plugins.git.BranchSpec> </branches> <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> <submoduleCfg class="list" /> </scm> <scriptPath>releasePipeline.groovy</scriptPath> </definition> <triggers /> </flow-definition>
The result is:
Started by user Dreyer Ulf > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url ssh://git@imbvl2vm294.bosch-si.com:7999/brm/vr-releng__release-scripts.git # timeout=10 Fetching upstream changes from ssh://git@imbvl2vm294.bosch-si.com:7999/brm/vr-releng__release-scripts.git > git --version # timeout=10 > git -c core.askpass=true fetch --tags --progress ssh://git@someServer.com:7999/someRepo.git +refs/heads/*:refs/remotes/origin/* > git rev-parse refs/remotes/origin/${branch}^{commit} # timeout=10 > git rev-parse refs/remotes/origin/refs/heads/${branch}^{commit} # timeout=10 > git rev-parse refs/heads/${branch}^{commit} # timeout=10 ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE
when it really should substitute ${branch} with 6.4.x as it does in the rest of the script.
Attachments
Issue Links
- duplicates
-
JENKINS-28447 CpsScmFlowDefinition does not resolve variables
-
- Resolved
-
Hi jon duffy, we are using the "Stash Pull Requests Builder" in a separate Task that is triggering the task that is using the Pipeline Snippet shown above.
The same pattern can be applied for regular parameterized Tasks.
In our case the plugin is monitoring Stash for changes and triggeres parameterized Builds when a Build is requested for a pull request, providing the parameters that are needed to build it.
If you are interested in further details, have a look at the Stash Pull Request Builder Wiki.