Jenkins JIRA Trigger Plugin Only Triggers 1 Job - jenkins

I've setup a webhook trigger from JIRA to trigger a Jenkins job.
This works fine for 1 particular Jenkins job, I can see the JIRA content coming in and the test Jenkins job runs fine.
However I can't get any other jobs to run from the webhook. Even if I copy the job that works correctly, that doesn't trigger either and I can't see anyway of debugging the issue.
Can anyone help shed some light on my issue please?
Thanks

I would recommend you to use the Generic Webhook Trigger plugin, you can add a Token that will help you specify which job you need to run for a specific webhook.
https://plugins.jenkins.io/generic-webhook-trigger/

Related

Trigger Jenkins Job from Bitbucket on Pull Request

Hoping to gather insight from professionals. My end goal is to trigger a jenkins build whenever a bitbucket pull request happens. If anyone could give me an ELI5(explain like I am 5) answer it would be greatly appreciated. Sorry if this is the wrong format, I am new to jenkins and stackoverflow.
What I have done so far:
Created webhook in bitbucket and gave the url to my jenkins job. example: http://jenkinsURL:8080/job/boulevard-dev/generic-webhook-trigger/invoke?token=myPull_Request_Token
Pull request webhook trigger
In Jenkins, under source code management I have: Source Code Management Settings. This is currently fetching a ton of branches, failing, then building the master branch when the job starts?
For build triggers, other stackoverflow articles have pointed me to the "Generic Webhook Trigger". https://github.com/jenkinsci/generic-webhook-trigger-plugin
I am not entirely sure how this generic webhook trigger should effectively be setup? Hoping someone has experience using it and could explain what is needed.
This is what have seen referenced in other articles.Build Triggers settings Build triggers settings 2
Questions:
What does a correct setup / example of the generic webhook trigger look like?
Currently, my job triggers when a change is made to master or merged to master, how can I specify to my job that I want the bitbucket pull request branch to be built?
Also, I found this, not sure if its related to my issue or not? https://jira.atlassian.com/browse/BCLOUD-5814
As per your requirement, you can trigger a Jenkins build whenever a bitbucket pull request happens by following the below steps, in my case, it's working fine.
Step(1) - Configure Jenkins
(i) Add your bitBucket repo and branch to source code management
(ii) On build Triggers setup Poll SCM to * * * * * for run every minute to check pull request from bitBucket.
Step(2) - configure Bit Bucket Hook
(i) Go to settings and add a new hook, now setup pull request trigger as per your requirement.
Step(3) - Make a pull request and see the new job automatically triggered on Jenkins.

Trigger builds when gitlab merge requests accepted on jenkins doesn't work

I can't find a way to trigger builds on jenkins when a gitlab merge request get accepted.
Here is my job configuration :
jenkins version : Jenkins ver. 2.107.3
gitlab version : 11.2.3
My webhook configuration on gitlab :
I tried, to select push events and accepted MR events on jenkins side, it works but for each push !
I want to know if this is the only way to get that works (push + accepted MR events).
Logically i just have to select accepted Mr only, but i get nothing, it doesn't seems to work that way.
I checked jenkins issues and find this one, i don't know if this is the same issue ? https://github.com/jenkinsci/gitlab-plugin/issues/636
Can you help me please, any ideas ?
Thank you.
you have to double check because i have same scenario and it's working fine
I dont find any solution so far using the plugin alone, and as I read this plugin is not directly developed by gitlab, my combo solution so far is:
to have a freestyle job, with configured webhook, where I can choose the MR events I need (Opened/Accepted/Closed) and retrieve all gitlab variables like gitlabMergeRequestState
from this job call another job defined via a fully elaborated pipeline, passing that gitlab variables, where all needed details can be handled via gitlab API.

Trigger jenkins from JIRA-workflow

we have jenkins CICD automated pipelines working great. we also trigger it via REST API with build Parameters.
Now, we have JIRA dashboard having custom workflow created where developers moves or changes queue of issues/stories to "ReadyForDeployment" once development is completed.
Now here, once developer moves queue to "ReadyForDeployment" :-
JIRA should prompt for 3 fields (ENV, PACKAGE_NAME_APP and
PACKAGE_NAME_DB) those will be placed in jenkins URL like
blahblahblah/buildWithParameters?ENV=${ENV}& PACKAGE_NAME_APP=${PACKAGE_NAME_APP}&PACKAGE_NAME_DB=${PACKAGE_NAME_DB}
Basically upon queue change,webhook should be triggered whcih
will take input/parameters from JIRA itself.
Please let me know your thoughts on this.
It depends on your requirement whether its correct or not. But it can be possible to trigger jenkins from Jira useing Jira-weebhook and passing the parameters.
https://developer.atlassian.com/jiradev/jira-apis/webhooks

Jenkins, read information from another job

I have a job "Project-A" in Jenkins which runs every 1 hour. I have another job "Project-B" which runs once in a day. When the job "Project-B" is triggered, I will pass "project-A" name as parameter, it will read the last successful build information of Project-A, such as build_id, in which slave node the build was run, timestamp etc. I am doing this via curl and Jenkins API.
Would like to know is there any better way to do this. Instead of curl. groovy or anything better? or any plugins to achieve this.
Thanks

How to trigger a Jenkins job from a status change in Jira

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

Resources