How to trigger a Jenkins build on a Perforce submit - jenkins

I am using Jenkins with Perforce. I have downloaded the P4 Plugin, and I have read over the documentation but I am still a bit confused. In my Jenkins project, I have the build trigger set to "Perforce triggered build". I'm assuming that means I need to add a trigger to Perforce that tells Jenkins to run a build, but I have no idea on how to do that.
I have not been able to find any documentation on how to implement a trigger from Perforce to notify Jenkins it needs to run. I can find documentation from Perforce on how to setup basic triggers, but I can not find anything from Jenkins on how to set up the actual connection to trigger builds on Perforce submits.
On the "Changes" tab in Jenkins, I am able to see the what was submitted to Perforce, so I know that Perforce and Jenkins are at least communicating. Initially, I thought that Jenkins would just automatically run the build on a Perforce submit, if I had "Perforce triggered build" checked, but that doesn't seem to be the case.
So my questions are:
Am I correct in assuming that I need to manually create a trigger to be added to Perforce?
If so, does anyone know of any documentation or examples that I can look to as a guide?

Yes, you need to add a trigger to Perforce. It's well documented here.

Related

Add jenkins job sonar scan into "Require branches to be up to date before merging"

I'm setting up Jenkins job sonarqube scan code in the github PR but I dont know how to integrate the name of jenkins job can define in "Require branches to be up to date before merging". My purpose is whenever new PR comes, sonarqube scans code before accept to merge or not.
Please let me know if you have any idea, thanks!
I can't provide a full answer for you, but I'll clarify some of this.
None of these "branch protection rules" have anything to do with SonarQube scans.
Typically, you will want to configure your SCM repository system so that when a pull request is created, it spawns a Jenkins build, which can do whatever it needs to do, including running a SonarQube scan on the code in the pull request branch.
Github, like other similar repository technologies, will have a way to detect the creation of the pull request. That will include configuration of the Jenkins connection information. There are different ways of doing this.

Jenkins Query and Trigger Gerrit Patches

I am using Jenkins 'Gerrit Trigger' to configure if there is any patchset uploaded to Gerrit server, then the Jenkins job will be triggered.
But unfortunately, there is some issue that some of the patchsets are not being triggered. I tried to use Jenkins 'Query and Trigger Gerrit Patches' to get those missed patchsets that are not being triggered. And I select one by one to trigger those patchsets manually.
I would like to ask is there any automated way to get those missed patchsets query and run some command to trigger the Jenkins job to run??
As you are able to use the 'Query and Trigger Gerrit Patches' in Jenkins,
it suggests the problem is related to disconnects or some load on the Jenkins-side
that causes it to miss those triggers.
I suggest reviewing the Jenkins-log, looking for errors related to the Gerrit Trigger.

Do Jenkins multibranch Pipelines allow remote triggers?

I am trying to to allow my multibranch Jenkins Pipeline to be triggered from a script. However each time I check the box and enter my token name and hit save, it does not save the configuration. When I next hit edit configuration the checkmark next to "Trigger builds remotely" is no longer checked.
Is this intentional? Do MultiBranch Pipeline jobs not support remote triggers?
Actually, for now, it is possible to trigger the build of a multibranch pipeline, but the token is simply ignored.
If you go in a branch of your multibranch pipeline and go to "View Configuration", you can try to check "Trigger builds remotely (e.g., from scripts)" and see that it gives you a link like JENKINS_URL/job/<your-multibranch-pipeline>/job/<your-branch>/build.
That sounds a bit like a hack, and you might have authentication problems depending on your setup, but otherwise it does trigger the build with Jenkins 2.30.
I have the same problem. Haven't found a solution yet, but there is a bug report open against it.

Jenkins and GitLab: How to setup SCM aware job which is not triggered by the hook?

To give some context the question is about GitLab and Jenkins setup.
I know how to setup a web hook, I know how to setup a job to be triggered by the hook. The problem is that I need to have multiple jobs and only a single entry-point (parent job) trigger for them.
The downstream jobs at the same time need to be git repo aware so I have to set repo url for them. This causes them to be triggered independently by the hook and I don't want that as this means that they are triggered twice.
On the other hand if I don't configure repo url on a downstream job and the parent job triggers it, it fails as it is not able to do a checkout.
I may try to hack around with some 'execute shell' build step, I believe it's not a valid way to go. Has anybody a good tip how to solve that?
For the reference here is the GitLab Jenkins plugin documentation according to which:
Plugin will parse the GitLab payload and extract the branch for which
the commit is being pushed and changes made. It will then scan all Git
projects in Jenkins and start the build for those that:
match url of the GitLab repo
match the configured refspec pattern if any
and match committed GitLab branch
I tried playing around with different settings, without a great result though.
For the project you want to get only local triggers, just enable Don't trigger a built on commit notification in the Additional behaviours of git plugin.
(https://github.com/elvanja/jenkins-gitlab-hook-plugin/issues/11#issuecomment-35385032, as you actually have discovered).
But a better solution could be to make your downstream jobs reference the repository locally cloned by main job (not sure if actually possible), so the plugin will never consider them for schedule a build, as the git url don't match.

Gerrit trigger install for Jenkins

I'm completely stuck with Gerrit Trigger install. I installed Jenkins ver. 1.482 with the Gerrit Trigger (v2.6.0) plugin. I'm not able to configure it.
I installed a test gerrit server (v2.4.2). I have an admin user. I tried to configure Gerrit Trigger to use this access to build patches (this is a test system, I didn't want to bother to add real users).
In Gerrit Trigger options I configured gerrit access. Test connection button says conection is ok. Although I get The connection to Gerrit is not started yet. Check the Gerrit URL in the settings. warning on the top. I also tried to push restart at the bottom.
I've read documentation on both Hudson and Jenkins page of the plugin. I'm still unable to configure the plugin.
Do you have any idea what's wrong?
Probably Click the button to Save after testing, this is common mistake that you forget to save it !! I met this several times
See more explanation in https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger
Otherwise it is not clear what's your problem since this is a normal case.

Resources