Jenkins missing Build Trigger section after upgrade - jenkins

I've upgraded Jenkins version (now on 2.127) and plugins and now the UI of job configuration is different and I am missing the build triggers section, especially the Trigger Builds Remotely via authentication token. Where is it? Do I need to enable it explicitly? The changelog unfortunately does not mention anything about that and I even can't schedule builds periodically.

Finally found out: It seems that since the update, the Multibranch Pipeline does no longer have this section. So either choose Pipeline or set it in the Jenkinsfile via: https://github.com/jenkins-infra/jenkins.io/blob/c0828af5b8bd428815e23537c808cd0267017013/Jenkinsfile#L6
The webhook works without a token with the Generic Webhook Plugin.

Related

Jenkins trigger build URLs

When I configure the job in Jenkins I see the following build trigger URL example:
JENKINS_URL/job/pipeline/build?token=TOKEN_NAME
However, I see a different URL on the Subversion plug-in's page:
http://server/subversion/${UUID}/notifyCommit?rev=$REV
Why are these URLs different? Do they serve different purpose? I assume that contacting the first URL will trigger Jenkins build, and the second one will update SVN working copy used with build jobs.
Why does the plug-in require repository UUID to be present in the URL? Is it required for svn:externals discovery?
Jenkins has multiple different build triggers. "Trigger builds remotely" is one such build trigger, and it takes the following URL format:
JENKINS_URL/job/testgrid/job/testgrid/build?token=TOKEN_NAME
The Subversion hook based build trigger is another build trigger. This is provided by the Subversion plugin which can register its own Servlet/URL. There are other plugins like GitHub plugin (JENKINS_URL/github-webhook/), generic webhook trigger (JENKINS_URL/generic-webhook-trigger/invoke) that register their own URLs as well.
These are different ways of triggering builds. Depending on the plugin used, they may provide specialized functionality though. In your case with Subversion plugin, the $REV parameter tells Jenkins to check out exactly the revision which was reported by the hook.
Here's a screenshot of the build triggers section with trigger builds remotely and GitHub hook trigger enabled:

How to trigger a Jenkins build on a Perforce submit

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.

How can I get notified if part of my build fails prior to running my Maven goals with Jenkins?

I’m using Jenkins v 1.61 with Java 7. I have a Maven job set up, using SVN for Source Code Management. I have a “Run buildstep before SCM runs” set up (courtesy of the pre-scm-buildstep plugin) and a pre-build step (a short script) set up prior to the Maven goals being run.
My question is, if any of these steps fails, how can I get notified via email of the failure?
Use Jenkins Mailer Plugin, This plugin allows you to configure email notifications for build results.
Plugin ID mailer
Latest Release 1.18
Latest Release Date Sep 04, 2016
Required Core 1.625.3
E-Mail notifications are configured in jobs by adding an E-mail notification Post-build Action. If configured, Jenkins will send out an e-mail to the specified recipients when a certain important event occurs:
Every failed build triggers a new e-mail.
A successful build after a failed (or unstable) build triggers a new
e-mail, indicating that a crisis is over.
An unstable build after a successful build triggers a new e-mail,
indicating that there's a regression.
Unless configured, every unstable build triggers a new e-mail,
indicating that regression is still there.
How about combining pre-scm-buildstep, conditional-buildstep and any-buildstep plugin.
This should allow you to run a publisher step like sending email notifications on a regular build step or a pre scm build step (feature provided by any-buildstep plugin). You could also add a condition check (feature provided by the conditional-buildstep plugin) on the pre-scm-buildstep phase.
You've mentioned that you use a short script prior to the pre-scm-buildstep, just in case you're exporting environment variables as input for your conditional check, remember that you'll also need to write that to a properties file (SEND_EMAIL=true >> my-job.properties) and use env inject plugin to load them on your job environment variables, freestyle jobs don't persist exported shell variables on build steps to be visible to the next steps that come after it.
Lot's of plugins right? Quite annoying. If you want something more elegant, I would recommend using pipeline as code plugin and wrapping everything on a try/catch/finally block, so you could raise an exception before the code checkout stage given a failed check, there are some examples in this article.

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.

How to get URL of pipeline job in jenkins

We are setting up a continuous delivery pipeline in Jenkins, using the build pipeline plugin.
Our deployment steps uses a proprietary deploy tool (triggered by a HTTP request from jenkins), but we need to have an additional Jenkins step for acceptance tests on the then deployed project. So our deploy tool will need to trigger the last pipeline step.
The jenkins setup for this is obvious:
For a Manually Triggered downstream build step: To add a build step
that will wait for a manual trigger:
Select the Build Pipeline Plugin, Manually Execute Downstream Project check-box
Enter the name(s) of the downstream projects in the Downstream
Project Names field. (n.b. Multiple projects can be specified by using comma, like "abc, def".)
Source: Build Pipeline Plugin
The problem is: I can't seem to find a way to trigger this downstream build through a URL.
In fact I'd need the URL in the deploy job, so I can send it to the deploy tool as a callback URL. Can anybody help?
If I understand correctly, you want to use remote access API, which to my knowledge is no different between general project or pipeline one.
Take a look here:
https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
Submitting jobs
Jobs without parameters
You merely need to perform an HTTP POST on JENKINS_URL/job/JOBNAME/build?token=TOKEN where TOKEN is set up in the job configuration.
As stated above by #rafal S do
read a file which has list projects name for which build job has to be triggered do a curl HTTP POST on JENKINS_URL/job/${JOBNAME from the file}/build?token=TOKEN within a for loop , where for loop has list of all project names from the file you read

Resources