Jenkins multi-branch pipeline - scm object of the Jenkinsfile? - jenkins

In Jenkins pipeline projects, I can reference the repo of the Jenkinsfile using the scm variable, e.g. checkout scm clones the exact repo at the commit that Jenkins uses for the current build.
Now, I am using a multi-branch project that gets the branches (and the corresponding source) from one repo, but the Jenkinsfile from another one. I.e. "Pipeline" is configured as "Pipeline script from SCM".
In that scenario, the scm variable during the build refers to the branch from the multi-branch config, not to the Jenkinsfile. How do I get the SCM object of the Jenkinsfile's repo?

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 multibranch - how to scan branches where jenkinsfile is placed on a submodule?

I have a main repository with a submodule which contains the Jenkinsfile . With this I want create a multibranch pipeline job for that main repository.
But it's not working. It works when the Jenkinsfile is not in the submodule but it doesn't detect the branches when Jenkinsfile its on the submodule.
How can I get the branches be detected when the Jenkinsfile is placed on a submodule?

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.

Jenkins BlueOcean missing branch and commit data?

I have a Jenkins file in the repository for MultiBranch pipeline.
I have a separate pipeline file for my toll gate into our integration branch. This is located in another repository. Executing it from a webhook from a BitBucket Server and both the branch and commit information is missing from BlueOcean?
Is there some way to set these values so they are picked up by BlueOcean UI?

Jenkins Multibranch pipeline fails if branch does not have jenkinsfile

I have a legacy build system on which I want to incrementally add multibranch pipeline support to branches so all branches will build and test for Continuous Integration. However ... old branches do not have a jenkinsfile present and a multibrach pipeline build fails with FileNotFoundException.
The pipeline works just fine on my new branches. It finds the jenkinsfile and runs the build fine. Can I have the pipeline filter out or ignore older branches that do not have a jenkinsfile?

Resources