Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a different jenkinsfile path with Blue Ocean

Summary

The Blue Ocean editor ignores the Script Path setting for the multibranch pipeline plugin and instead saves the Jenkinsfile in the repository root. Is this a bug?

Background

We have a single repository with several projects in it, so we're trying to setup many multibranch pipeline jobs, with each of them pointing to the same repository.

The first problem we encountered was that the Jenkinsfile which stores the pipeline code was stored in the root of the repository, the problem being that this was the same location for each Job. We subsequently discovered that as of June 2017 you can now specify a Jenkinsfile location per job in the multibranch pipeline plugin. Great.

Adding Blue Ocean into the mix: when editing the pipeline in the Blue Ocean editor it seems to be disregarding the Script Path setting, and instead saving the resulting pipeline code in a fixed location (the root of the repository). When the job runs however, it picks up the correct location, so it seems to be a bug with the editor.

We've searched the Blue Ocean backlog but can't find an existing issue, could we have discovered a new bug? We're very new to Jenkins, so I'm not sure if a) we're not setting this up correctly or b) Blue Ocean isn't expected to work this way.

Configuration

Multibranch Pipeline Job 1
Name: Foo
Repository Name: test
Build Configuration -> Script path: Build/Jenkins/Foo/jenkinsfile

Multibranch Pipeline Job 2
Name: Bar
Repository Name: test
Build Configuration -> Script path: Build/Jenkins/Bar/jenkinsfile

The sample repository has 2 branches, master and dev.

like image 247
Red Taz Avatar asked Nov 15 '17 14:11

Red Taz


People also ask

Can we have multiple Jenkinsfile?

Jenkins pipeline allows you to have a flexible Jenkinsfile with stages for your build. So you can have an initial stage where you run linting, tests, etc., and then separate stages for building artifacts or deploying them. This is very useful when you want to do multiple things in your pipeline.

Is Blue Ocean good for Jenkins?

It is the preferred tool for Jenkins Pipeline creation, as it provides online help for the Pipeline steps available in your Jenkins controller. It uses the plugins installed on your Jenkins controller to generate the Pipeline syntax.

Which one enables you to implement different Jenkinsfile for different branches of the same project?

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.

How do you integrate Blue Ocean Jenkins?

To install the Blue Ocean suite of plugins to your Jenkins instance: Ensure you are logged in to Jenkins as a user with the Administer permission. From the Jenkins home page, select Manage Jenkins on the left and then Manage Plugins. Select the Available tab and enter blue ocean in the Filter text box.


1 Answers

This bug is fixed in BlueOcean 1.22.0

like image 176
nandilov Avatar answered Oct 21 '22 18:10

nandilov