Trigger Jenkins Multibranch Pipeline Scan from another job - jenkins

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

Related

Jenkins is not automatically triggering the multibranch pipeline scan when a push is made to bitbucket

I have successfully established a multibranch-pipeline project and even managed to integrate it with bitbucket using webhook, however, Jenkins is not triggering a multibranch pipeline scan whenever I am making a new commit. I have to manually scan the multibranch pipeline for new commits so that jenkins can trigger a new build but I want to automate this as well, can somebody help me with this? thanks.

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

Is there a way to have jenkins only automatically trigger a build for new PRs?

I am using Jenkins pipelines and the Bitbucket plugin
I can Suppress automatic SCM triggering but that suppresses everything
Is there a way to have Jenkins track all my branches, PRs, and tags in the multibranch pipeline but only automatically trigger a build for new PRs and not branches or tags? But still have it possible to manually trigger a build of any branch or tag.
I could have logic in the pipeline that exits if the build is not user initiated and is not a PR- but is there a config option to do that sort of thing for me?

How to get the Generic Webhook Trigger Plugin to work with multibranch pipelines in Jenkins?

I'm trying to set up a scenario where a pull request is created on github that triggers a Jenkins multibranch pipeline, and where that multibranch pipeline uses the Generic Webhook Plugin to extract values from the POST request sent from github to jenkins to be used in the script.
Unfortunately, as described on the Generic Webhook Trigger Plugin wiki:
Note: When configuring from pipeline, that pipeline needs to run once, to apply the plugin trigger config, and after that this plugin will be able to trigger the job. This is how Jenkins works, not something implemented in this plugin. You can avoid this by using Job DSL and have Job DSL create pipeline jobs with the plugin configured in that DSL.
This would be OK using a normal pipeline since it would just be a one off on creation of the Jenkins job. The problem however is that a multibranch pipeline will create a new job whenever a new branch/PR is created, and that means that for each pull request I create on github (which triggers my multibranch pipeline script), I have to then run it twice to get the generic webhook functionality working. Having to resubmit for each PR would be tedious for long-run projects.
It seems to me like there are two possible approaches to solving/improving on this problem. One is to try and play around with DSL Jobs (as suggested by the wiki); but I tried this and couldn't get it to work (it was adding a huge amount of complexity to the set up, so I've abandoned it for now).
The second possible solution is as follows: when a PR is created in github, the Generic Webhook will cause a new job to be created in the multibranch pipeline corresponding to that PR; the first time the multibranch pipeline runs the first build of this newly created job will fail for the reason given in the quote above; but then a solution might involve testing that the first job failed and somehow telling Jenkins to try rebuilding for that job again.
So my question relates to this second approach: how can I most neatly run a rebuild for this multibranch pipeline upon the creation of a PR on github?
Any advice/suggestions would be appreciated!
For triggering multibranch pipline by webhook you can use this plugin:
"Multibranch Scan Webhook Trigger"
https://plugins.jenkins.io/multibranch-scan-webhook-trigger/
Actually that is not true for multibranch pipelines. Just ordinary pipelines needs to run twice.
I updated the docs like:
When configuring from pipeline (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:

Resources