by jsmeaton · 9y ago · 0 comments
We decided on creating a new job of type pipeline, and pointing it at a script named `Jenkinsfile.deploy`. It has a few parameters, namely `BRANCH`, that can be manually set, or passed in from another job. We can then move our deployment steps from the main Jenkinsfile into this new one, and still version control the lot.
Major caveat is that the deploy step is not compatible with organisation scans (multibranch/pr), but that's fine for our use case. We usually want to trigger our builds manually based on the branch.
https://gist.github.com/HRMPW/9b2a3ccbdc370e0a7c9cb541be229d...
This is a Job-DSL seed job written in Declarative Pipeline that pulls in your Organization based on a build parameter and creates two jobs for every repo:
1. A multibranch Pipeline job that is based on the Jenkinsfile that will work across all branches and PRs.
2. A deploy job for the repo that is defined in a "jenkinsfile.deploy" file in the repo. This isn't a multibranch job but can be run on any branch based on a parameter for the branch.
This is a very simplistic implementation but could be expanded on further.