Passing branch parameter from Jenkins to Spinnaker

I have Spinnaker pipeline setup to be triggered from a Jenkins job. Is there a way to pass a parameter from Jenkins to a Spinnaker pipeline with the GitHub branch that we would like to build? If so, how can it be done?

1 Like

You can pass a property file from Jenkins to Spinnaker. You will need to archive a file with the branch info as a part of your Jenkins job and specify the file in the Property File field on the Jenkins trigger in Spinnaker. From there, you can reference the branch through pipeline expressions.

Check out for more information.


Thanks for the info. I’m having a little trouble trying to figure out how to pass the property file from Jenkins to Spinnaker. On the Jenkins job that is used to trigger the Spinnaker pipeline, I’ve added a “Post-build Actions” > “Archive the artifacts” > “Files to archive” and specified a file name to archive. Is that how to do it? If not, can you provide some more details on it’s done?

Also do you have an example of how the property files is used once it’s passed to Spinnaker? I’m having trouble figuring out the correct syntax from the pipeline expressions guide.

Yes, that is the correct way to archive the artifact properties file. After running a build, you should see that file you specified under Build Artifacts section in the status page of that Jenkins build. From there, you add that file name to the properties field in the Jenkins trigger on Spinnaker, and Spinnaker will pick up that the properties in the next pipeline run. You can check if the Spinnaker picked up the artifect properites by looking at the execution json of a pipeline with the Jenkins trigger. The properties should be populated in the section of the json.

For an example,
Our property file looks like:


and in the comments section of our bake stage we add


how do I do this? Should I create a property file in the git repo or where else? Can the jenkin job write the branch name to the property file during the execution of the job?

If you commit it to the git repo, it wont be as dynamic, unless you have some bash code to append to that file dynamically.

We add something like this near the end of our jenkins jobs, which then can be used within a pipeline.

echo "---
" > build_properties.yaml

Thanks Sijis. this helps but from there, can you pass it to the git trigger that we use in configuration stage of spinnaker pipeline. I guess pipeline expression cannot be used in configuration stage of spinnaker pipeline? I’m trying to add the branch name dynamically to the GIT Trigger in spinnaker pipeline. Is that possible in any mean?

From that file, you can use ${[‘GIT_BRANCH’]} in any of your pipeline stages.

You will have to setup the trigger as such:

The rest of that page gives pretty good examples on what can be done with pipeline expressions.

but that document says that pipeline expression cannot be used in configuration stage but GIT trigger is only available in configuration stages. With that restriction, how to parse the Git branch name in configuration stage in the Branch textbox of the attached image assuming we cant use pipeline expression over there

I suppose not being able to use an expression trigger in the config state would make sense, as that’s what is initiating everything and where you are likely getting any data from.

A way to make that dynamic, is to write tooling that automatically creates/updates a pipeline when a change is desired.

For example, let say in an application repository you have a file named deployments.yaml, with the contents with something like:

git_trigger_branch: master
jenkins_job: myapp-job-test
slack_channel: #app1-dev

When you detect a change to that file, then your tool/script (or maybe Spin) will create/update a pipeline for app1 by using some of the data in this deployments.yaml file.

These are just ideas to help you work around some limitations.

Hi Sijis,
I am trying something similar. I wanted to pass on the commit id from Dev stage to manual approval and thereby to complete pipeline. I am writing the commit id at the end of the jenkins job to a gitcommit.yaml file and mentioned that as the property file on Dev Build and Deploy stage. I am getting error on the produces artifacts section.