Jenkins multibranch with Jenkinsfile in different repo - jenkins

If use a multibranch pipeline in Jenkins, I want to have a build for every specific branch that is made inside my code repo. This works like a charm. But I don't want to provide a Jenkinsfile inside my code repo. Instead I want to define a different CI repo which is providing my CI pipeline scripts.
The problem is that the usual config is not containing the scm option like in the normal config.
Normal pipeline config:
Multibranch pipeline config:
Can somebody tell me how to separate the Jenkinsfile from my source code using a multibranch pipeline?

Just in case someone stunmles over the same problem,
there is a Jenkins plug-in which brings remote Jenkinsfiles for mutlibranch pipleines: https://plugins.jenkins.io/remote-file/

Related

How to build jenkinsfile from a repo which triggered jenkins job when using multiple repositories in SCM in one jenkins pipeline?

I have multiple repositories which require a cd pipeline and all the repositories have their own jenkinsfile with same name. I have configured one jenkins pipeline for all the repositories by adding multiple repositories in "pipeline script from SCM" section.
When any of the repository is updated the pipeline triggers but it uses jenkinsfile of the first repository mentioned in the list of repos.
Is their anyway we can change this behaviour and make the Jenkins job run Jenkinsfile from a repository which triggered the build.
This can be done by shared library https://www.jenkins.io/doc/book/pipeline/shared-libraries/
https://www.tutorialworks.com/jenkins-shared-library/
You can define various logic and functions to manage multiple repositories and their variables.
Also, try to make generic script which can behave based on the supplied parameters.

Ho do I restart the jenkins pipeline with an updated JenkinsFile

I have a Jenkins project with a declarative pipeline defined in a JenkinsFile stored in a SCM. I use the "Pipeline script from SCM" option.
Sometimes if something fails I do a quick fix in the jenkins workspace and rerun the pipeline starting at a specific stage. This is working nicely.
There are cases in which I need to update the JenkinsFile and then do a 'restart at stage' with the updated Jenkins file. However, I can't find the JenkinsFile anywhere in the workspace folder. I need to know the location so I can do a quick fix and then restart the pipeline. Where is the JenkinsFile located?
See "Replay" Pipeline Runs with Modifications:
The "Replay" feature allows for quick modifications and execution of an existing Pipeline without changing the Pipeline configuration or creating a new commit.

How to edit / define Jenkinsfile text within Jenkins job?

Sometimes it is not possible (yet) to put Jenkinsfile into git repository.
I think it was possible to edit/define Jenkinsfile content just within job,
but with latest Jenkins, I cannot find such support.
Now I see only filename configuration.
OK, just be sure to select usual Pipeline project and not Multibranch pipeline

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:

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

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.

Resources