Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins edit config in multi-branch pipeline

Tags:

I cannot find a way to edit the configuration of multibranch pipeline projects. When I change to the branch level, there is only a "view configuration" menu item, as opposed to ordinary pipeline projects.

I am looking for a method to configure build triggers from outside Jenkins. My current workaround (define a pipeline per branch) is not feasible beyond initial testing.

like image 867
rhoerbe Avatar asked Jul 26 '17 09:07

rhoerbe


People also ask

How do I configure multiple branches in Jenkins?

Step 1: From the Jenkins home page create a “new item”. Step 2: Select the “Multibranch pipeline” from the option and click ok. Step 3: Click “Add a Source” and select Github. Step 4: Under the credentials field, select Jenkins, and create a credential with your Github username and password.

Which of the below could be the use case of multi branch pipeline?

Multibranch Pipelines can be used for validating pull/change requests with the appropriate plugin. This functionality is provided by the following plugins: GitHub Branch Source. Bitbucket Branch Source.

How do you add parameters in Multibranch pipeline Jenkins?

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.


2 Answers

You can edit the overall configuration of a multi-branch pipeline project, such as the repo it will read from and any credentials it will need, triggers for scanning the branch to check for changes (Note: not the same as build triggers),orphaned item strategy, build configuration, properties, and a few other things. This can be viewed by clicking "Configuration" on the page that shows all the branches, or it will say it is empty if there are none.

Please note this only applies to multibranch pipelines that are not part of an organizational folder (not a "Bitbucket Team/Project" or "GitHub Organization" type project.)

enter image description here enter image description here


If you click a branch name (ex: master), clicking "View Configuration" will only let you view it. You have to edit the file defining that pipeline on the correct branch in order to change it. In the case of these screen shots, you need to edit the Jenkinsfile in the Test-Multibranch-Job repo on the master branch to edit the configuration.

To add a trigger mechanism, you could add triggers { gitlab(<config-here>) } to your Jenkinsfile if your repo is in Gitlab. Also note whether you are using a declarative pipeline or a scripted pipeline because the syntaxes are different.

enter image description here enter image description here

NOTE: I am running Jenkins ver. 2.92

like image 89
Wimateeka Avatar answered Sep 21 '22 19:09

Wimateeka


https://issues.jenkins-ci.org/browse/JENKINS-33900

"As designed, these jobs are view-only." -- Jesse Glick

you should be able to define the config in the pipeline itself, e.g. https://jenkins.io/doc/book/pipeline/syntax/#triggers

like image 41
eversMcc Avatar answered Sep 17 '22 19:09

eversMcc