It is possible to disable a multi-branch pipeline with:
https://my.jenkins.net/job/my-project/disable
It is possible enable a multi-branch pipeline with:
https://my.jenkins.net/job/my-project/enable
But I haven't found any API to get the actual status.
The following URL do not show any difference between a disabled/enabled multi-branch project:
https://my.jenkins.net/job/my-project/api/json
And the following URL do not show this famous "color" (= status) field for multi-branch project:
https://my.jenkins.net/api/json
Also, I can have the status of ONE branch, but this status is incorrect: when I disable the multi-branch project, and call this URL:
https://my.jenkins.ne/job/my-project/job/master/api/json
=> It returns the field "buildable" at true
How to retrieve the status we are able to change of the multi-branch project ?
There seems to be no Jobs API for multi branch pipelines that reports correctly status of the job disabled/enabled.
You can obtain this info from the job's config.xml:
https://jenkins.domain.com/job/Multibranch-Job-Name/config.xml
<disabled>true</disabled>
Related
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.
I'm trying to trigger a Jenkins Pipeline build (NOT MultiBranch Pipeline) when a specific format of tag is pushed to my GitHub repository. So any branch pushed to the repository will trigger a build if it is tagged with a format of Major.Minor.Patch e.g. 123.123.123
I've setup a webhook which works fine and hits Jenkins (I can see it in the Github Hook Log on Jenkins configuration page). But unfortunately it does not trigger the build.
I've tried setting the refspec to:
+refs/tags/*:refs/remotes/origin/tags/*
And I've accompanied this with a branch identifier:
:origin/tags/[0-9]+\.[0-9]+\.[0-9]+
I have read every article I can find, and scoured StackOverflow but I'm at a loss. I can make it work by setting the branch identifier to **/tags/** but this is too open and triggers a lot of redundant builds.
If anyone can assist in achieving this goal it would be massively appreciated. Also, I'm not certain whether I should be using Pipeline to MultiBranch Pipeline to achieve this?
Starting to lose faith that Jenkins is a good choice so before I jump ship please help!
Thanks!
I prefer using the generic webhook trigger plugin
This allows you to assign a token to a specific Pipeline job so that it will be triggered when your GitHub webhook sends a http request the job's corresponding url:
http://JENKINS_URL/generic-webhook-trigger/invoke?token={token-goes-here}
The Github docs describe the http payload content for a push event
You can parse the http payload using a JSONPath expression to obtain the tag string and then filter whether to run the Jenkins job using the Major.Minor.Patch regex
I've not tested it but here's what the pipeline code might look like:
triggers {
GenericTrigger(
genericVariables: [
[key: 'tagString',
value: '$.ref',
expressionType: 'JSONPath']
],
token: 'example-token',
printContributedVariables: true,
printPostContent: true,
// only trigger if tag follows Major.Minor.Patch regex
regexpFilterText: '$tagString',
regexpFilterExpression: '<tag-regex-here>'
)
}
I have Jenkins pipeline, and configured github webhook to trigger pipeline.
How to make triggering pipeline when the certain branch was pushed, instead of triggering pipeline by pushing to every branch ?
Webhook is generic for all, there is no filter on the side github or bitbucket, all you need to handle based on payload.
you can use Generic+Webhook+Trigger+Plugin,The plugin will allow you to parse certain data from the payload, and can conditionally trigger a build depending on the branch name.
Apply the filter with branch name
generic-webhook-trigger-plugin-specific-branch
I try to show some delivery pipeline instances in jenkins Delivery Pipeline View.
If the delivery pipeline instance is defined as ‘Free Style’ or ‘MultiJob Project’ everything works fine, but the Job does not appear in the Delivery Pipeline View when defined as ‘Pipeline’.
I tried the following:
my_pipeline-job as a Post-Build-action -> Build other projects (manual step) ->Downstream Project Names->my_pipeline_job
The result was a error message: my_pipeline_job cannot be build!
The message disappears when I tried to build it as:
my_pipeline-job as Post-Build-action ->Trigger parameterized build on other projects-> Build Triggers-> Projects to build->my_pipeline_job
But the results will not be shown in Delivery Pipeline View.
At present support for pipeline type projects in delivery-pipeline-plugin is in active development.
Refer the JIRA ticket for information & progress
JENKINS-34040
I have been looking for a while now for a way to trigger a Jenkins job from the status or a ticket/story in Jira changing status. To give a more detailed example when my team moves a ticket to the 'ready for test' column we would like to be able to trigger a sanity test pack in Jenkins, the ideal situation would then be that we are able to post the results (generated as a html) as a comment on the ticket within Jira. Failing that we would like to be able to publish the results as simply pass/fail.
I have recently been looking at the Jenkins Jira plugin but this does not seem to have the functionality to work both ways, in other words it can post results after a job has run but you cannot trigger the job from a change of status in Jira. Is there any such plugin available or is it something that we will need to create ourselves?
Cheers in advance
So, basicly there are webhooks in jira (https://developer.atlassian.com/jiradev/jira-architecture/webhooks). With it you can configure it to trigger specific url on issue status change. The specific url should be jenkins API, for example for triggering a build you should call an external url like (if you are building with parameters): http://server/job/myjob/buildWithParameters?token=TOKEN&PARAMETER=Value
Some more info https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
I have written a Jenkins plugin that supports JIRA status change trigger: jira-trigger-plugin.
This plugin also injects an environment variable of JIRA_ISSUE_KEY, so you can utilise this information to publish your result back to JIRA e.g. using REST API.
Please follow as mentioned below:
GIT:
You can set the web hooks for git/ bitbucket /stash on commit which inturn should change the state of task in JIRA.
JIRA:
Once you in JIRA. define the workflow for your task.
In this particular workflow you can set a post-function where the web hook should be configured. In this configuration of webhook in events define JQL as below:
status CHANGED FROM "To Do" TO "ready to test".
In the same mention the job that needs to be fired in the URL section.
You can look through webhooks in Jira :
https://support.atlassian.com/jira-cloud-administration/docs/manage-webhooks/
You also need to add the Generic Webhook Trigger plugin to your Jenkins :
https://plugins.jenkins.io/generic-webhook-trigger/
You can find here an example on how to use the Generic Webhook Trigger plugin with Bitbucket Github and Gitlab. https://github.com/jenkinsci/generic-webhook-trigger-plugin/tree/master/src/test/resources/org/jenkinsci/plugins/gwt/bdd
It involved multiple steps
If you are using Git/Stash/BitBucket (which i implemented),
You can simply
configure the commit hooks in your Stash/Bitbucket
Attach events to your JIRA workflow
Jenkins JOB - post build events - configure Notify
Stash plugin Set the Poll SCM
That's it