Jenkins BlueOcean only to build using a single branch for build? - jenkins

When I build a multibranch pipeline job using BlueOcean it looks into my repository and reads all of my Jenkinsfile for each branch. to initiates multiple build, but I only want to be able to build a job based on a certain branch. Is there a way to only build blueocean?
Thanks

I sounds like your job is a Multibranch Pipeline.
If you create a job that is just a Pipeline (rather than Multibranch Pipeline), you can specify a single specific branch to build.

Related

Can I specific a single Jenkinsfile for multibranch pipeline in Jenkins?

By default, Jenkins multibranch pipeline discovers branches of my GIT repository. It can execute the related Jenkinsfile for the target branch. However, this design force me to create one version of Jenkinsfile for one branch and this cause Jenkinsfile maintenance overhead.
If I can ensure I will have only 1 version of Jenkinsfile, is it possible for multibranch pipeline to point to such Jenkinsfile instead of referencing Jenkinsfile of the target branch?

Jenkins being run on all branches in repo instead of only the branch changed

I am pretty new to Jenkins, and when I make a pull request, the Github webhook triggers a rebuild on all branches in the repo. However, I only want the branch associated with the pull request to be built. I suspect that all branches are built due to nothing specified in the "Branch specifier."
Is there a way to specify to build only the branch the pull request was made to?
Thanks!
To resolve your issue try to use multibranch pipeline job or use filter in simple pipeline job.
To use multibranch pipeline job you need to install Pipeline: Multibranch plugin.
Pipeline job example
In simple pipeline job choose "Build when a change is pushed to GitLab" in "Build trigger" section -> Advanced -> Filter branches by name

Continuous deployment branch wise using Spinnaker

I'm using Jenkins multibranch pipeline for CI process and for CD using Spinnaker.
I've gone through almost all documents, support channels etc. from spinnaker for "how to create spinnaker multibranch pipeline similarly as jenkins" but didn't find anywhere.
After integrating jenkins to spinnaker, in drop down list of jenkins jobs in spinnaker pipeline configuration, it shows all multibranch jobs separately. Hence for each branch I'd need to go to spinnaker and create pipeline manually.
To solve this, I'm thinking this solution: while running jenkins multibranch pipeline job > create spinnaker pipeline(if not exist) using spin cli with required parameters(branch, version, trigger using jenkins of this running branch job etc) > and trigger the same created spinnaker pipeline after jenkins job executed.
Please advise if there is any other better way to accomplish this.
Thanks.
I am not super familiar with the multibranch plugin, but you can make this simpler by doing [ triggers ] -> [ pipeline stage calling the same pipeline ] rather than calling the entire pipeline via the spin-cli.
Alternatively, if the list of jobs generated is small or well known, you could just update the list of triggers for the same pipeline programmatically as part of your release process.
i.e, in your jenkins job
add this job to list of triggers
run rest of jenkins job
job finishes, spinnaker pipeline triggers

Multiple GitHub Checks with Jenkins Multibranch pipeline

I have configured Jenkins using Blue ocean multibranch pipeline and a Jenkinsfile to trigger a build when new pull request appear in a repo.
In this pipeline I have two stages that run in parallel, because they are independent tests. What I would like to achieve is to display two check results on the pull request page on Github, one for each stage.
Initially I though about creating two pipelines using two different Jenkinsfile, but it seems that multibranch plugin does not support this.
What is the correct solution to achieve this?
You can use plugin - https://github.com/jenkinsci/github-autostatus-plugin
The plugin can be configured to send commit status for each stage for jobs build from a multibranch project. For example:

Trigger Jenkins Multibranch Pipeline Scan from another job

Is it possible to trigger Scan Multibranch Pipeline Now action for a Jenkins Multibranch Pipeline from another Job? I have certain issues integrating my old version of Gitlab with Pipeline Jobs in Jenkins and came upon such a workaround.
Alternatively, would it be possible to trigger Scan Multibranch Pipeline Now with a notifyCommit web hook?
The purpose of this would be to Scan Multibranch Pipeline whenever a change occurs in the Git repo, so that new branches are detected after such a change.
Another purpose, which I am unable to achieve otherwise (except for periodic polling per branch which is plain evil to me), is to trigger build of branches affected by given changeset. I use old GitLab (7.8) which does not work with the ordinary Gitlab plugin and the Gitlab Hook plugin does not work with pipeline jobs, so my workaround would be to have an non-Pipeline Job to be triggered by Gitlab Hook plugin and this job would in turn trigger Scan Multibranch Pipeline.
Turned out that simple notifyCommit web hook did the job

Resources