Gerrit push to new branch does not trigger Jenkins job - jenkins

I have a very peculiar problem on my Jenkins. Gerrit trigger works on first master branch usually. When I create a new branch and push something to it, the build is not triggered at all. Even when I do Query and Gerrit trigger patch it does not work. But, when I open the job configuration, Save and do a manual trigger it works. The next consecutive push work as normal again.

Related

Run a build only when a MR is created

I'm trying to achieve the following: When someone creates a Merge Request in GitLab, a Jenkins job would be triggered that builds the source branch.
Problem is: It works, but it also builds the branch when the Merge is actually performed.
It should only trigger Jenkins when a MR (Merge Request) is created, not when it's merged. I thought about differentiating between a MR and a Merge with the environment variables but the environment variables for a MR and an actual merge are exactly the same in Jenkins so that doesn't help much.
Configuration:
In GitLab, I've created a webhook for Merge Requests
In Jenkins, I've created a build trigger that says it builds "only if new commits were pushed to the MR".
(I've tried using only "Opened MR events" or only the "only if new commits were pushed to the MR" option but then it doesn't work. [either builds on every action such as a comment or it either doesn't work on a new Merge Request.])
It seems like it's impossible to have Jenkins only trigger a build only when a Merge Request is created. Am I wrong? Is there another way of doing that? Thanks ahead!

jenkins generic webhook trigger git. Option Filter not working

I am using jenkins generic webhook trigger git. i want to trigger build only when a push is made on branch which starts with PO.Used optional filter as ^(ref\heads\PO-[a-z0-9_-])+$ but was not working, can someone please help. when Optional filter is blank. the build gets triggered on master branch.

Trigger building the Github's webhook head_commit in Jenkins

I have configured a Jenkins Pipeline that correctly receives webhooks push notifications from GitHub, on push events.
The authentication is done through a deployment key.
Jenkins configuration seems to rely a lot on the concepts of branches and pull requests.
Given my workflow, which consists mostly of creating branches for any needs, and merge changes back onto master once things would look fine on the CI, I do not really care about seeing my builds categorized by branch or PR.
I would prefer to see builds based on commits' hashes. I do not see the need to tell Jenkins what branch I want it to match.
My current configuration is not selecting the commit revision I desire. I do not understand how it decides which branch or commit to build, once it receives a push notification. In Jenkins I have set the branch to **.
Checking the webhook payload, I noticed that it contains both the list of commits but also something called head_commit, with its id property being the commit's hash I want to see being built.
I would like Jenkins to do the following:
Check what's the head commit in the webhook notification (head_commit.id in the payload)
Build that precise commit, no matter the branch it is part of
Setting a green tick or a red cross beside the commit's hash on Github
Is this possible?

How to trigger a Jenkins job if other job was successful? (not automatically)

I have 2 Jenkins jobs which get triggered when different changes are pushed to GitHub (either one can also be run manually). Is it possible to make a job depend on the other one as well? Let's say I have job A and job B, I want A to be triggered when a push happens on GitHub (this is already working) and B to be triggered when a push happens on GitHub only if the last build of A was successful (so I don't want it to be triggered automatically after A)
Could we skip the GitHub push checking on B? We checked it by A. Just trigger B if A was successful.
A push happens on GitHub
Trigger the A
If the last build of A was successful, trigger B (use the curl tool...?)

Jenkins Email-ext plugin not sending notification when new branch fails for first time

Steps to reproduce my problem:
Using GIT for SCM and Jenkins is set up to trigger build on SCM change
Master branch is building fine and all tests are passing
Create new branch from master
Break something so build fails and push to the new branch
Build is triggered in Jenkins by SCM change
Expected result is that email-ext plugin sends notification of build failure to the person who first pushed to the new branch.
But actually no e-mail is sent and the log says:
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE
The "Failure - Any" trigger has both Developers and Culprits set under "Send To".
When a second commit is made to the new branch by the same person, the trigger works fine - it finds the e-mail address of the culprit and sends the e-mail.
Using Email-ext version 2.38.1, Jenkins 1.575.
The triggers I have configured:
Screenshot from the first failing build after creating a new branch is below. (Branch is immediately broken)
I think the problem might be that it says "No changes", although it is triggered by a SCM change.
If it is changed with a second commit, it will show that commit under "Changes" and then it knows who to send the e-mail to.
Any way to get the plugin to send an e-mail to the one who creates the broken branch? Thank you.

Resources