I am setting up a Jenkins multi-branch instance which needs to allocate a resource on branch job creation when a new branch is detected by the https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin plugin (version 2.21), and deallocate it when the branch job is deleted by the Multi-branch pipeline when the branch is not present in Git any more.
(To be precise, we need to ship the built binaries to an OpenShift deployment which needs to be explicitly set up and destroyed for each branch).
I have looked at the documentation, but not yet found the location where this can be configured. To my untrained eye, this would make sense to be a "stage" outside the "stages" node, but it is the same for all builds, so it could also go outside Jenkinsfile.
How can I do this?
Head over to your Jenkins instance and create a new item. Enter a name for the job, and select the “Multibranch Pipeline” option at the end of the screen. Then, click on the OK button. In the next screen, go to the “Branch sources” tab, click on the “Add source” button, and choose “Git” from the dropdown menu.
If you want to add new parameters you have to do it using properties in Jenkinsfile - goto <JENKINS URL>/pipeline-syntax and generate code for the properties step.
The Multibranch Pipeline project type enables you to implement different Jenkinsfiles for different branches of the same project. In a Multibranch Pipeline project, Jenkins automatically discovers, manages and executes Pipelines for branches which contain a Jenkinsfile in source control.
Multibranch Pipeline Vs. It can be use used for Gitlab, Bitbucket teams, or Gitea organization. Mullitbranch pipleine can only configure pipelines for a single Git repository. Whereas a Jenins Github organization project can automatically configure multi-branch pipelines for all the repos in a Github organization.
You can use the MultiBranch Action Triggers plugin. With this plugin you run external jobs on branch creation/deletion. You need to create external pipelines which will do things on OpenShift.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With