Trigger Jenkins builds using Jira Automation

mayank goyal July 3, 2021

Hi Everyone,

I am trying to trigger Jenkins build using Jira Automation, but it's failing. I am getting "No valid crumb was included in the request" error even after passing the Jenkins-Crumb header.

Configuration:

Screenshot 2021-07-03 160617.png

Error:

Screenshot 2021-07-03 160932.png

 

Also, I mention that when i try the same request using Talend API tester It works fine.

Screenshot 2021-07-03 161414.png

3 answers

1 accepted

3 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2021

Hello @mayank goyal ,

Welcome to the Atlassian Community!

According to the Jenking Remote Access API documentation page, basic authentication with username and api-token has to be preferred over crumbs for CSRF protection:

Remote API and security

When your Jenkins is secured, you can use HTTP BASIC authentication to authenticate remote API requests. See Authenticating scripted clients for more details.

 

CSRF Protection

Note: API tokens are preferred instead of crumbs for CSRF protection.

 

Also, according to the Authenticating Scripted Clients, the content-type header is not needed:

Shell with curl

The curl command is available for most operating systems including Linux, macOS, Windows, FreeBSD, and more.

curl -X POST -L --user your-user-name:apiToken \
    https://jenkins.example.com/job/your_job/build

 

Therefore, can you kindly do the following and let us know the results?

  1. Create an Api Token in Jenkins
  2. Send a REST API call using Curl like in above example
  3. If the call fails check what went wrong, otherwise configure the Send Web request automation action the same way and run it
  4. Trigger the Automation Rule and check if this time is succeeding. Provide the outcome otherwise.

 

Cheers,
Dario

mayank goyal July 6, 2021

Hey Dario!

Thanks a lot, this worked really well. :-)

I want ask a question: Last time when I was trying with username:password it was failing in jira automation but succeeded with Talend API tester.

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 7, 2021

Thanks for your quick reply @mayank goyal ,

 

However, I am not sure I understand what the question is, can you kindly try to reformulate?

mayank goyal July 7, 2021

Yes sure.

When I was trying to trigger the Jenkins job using username:password it was failing in Jira Automation (reason I asked this question). But when I tried to trigger the jenkins job using same way i.e username:password in Talend API tester it worked (screen-shot attached below).

So why username:password authorization is failing in Jira Automation while it's working fine in Talend API test.

EDIT: In the Talend API tester I am able to trigger the jenkins job even without username and password (only with Jenkins-Crumb)

I hope question is clear this time. Please let me know if it's unclear. :)

 

Screenshot 2021-07-03 161414.png

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 7, 2021

Hi @mayank goyal ,

The question is crystal clear now, but not having access to Jenkins logs I can just guess that the REST API call fired by Automation for Jira was somehow different than the one sent by Talend API tester :) 

Maybe in Jenkins logs you can find more information on why it failed.

Also, just to make sure I understood correctly, can you confirm this is actually working now?

 

Cheers,
Dario

mayank goyal July 7, 2021

Hi Dario,

>> Maybe in Jenkins logs you can find more information on why it failed.

Thanks, I will try to debug the logs.

>> Also, just to make sure I understood correctly, can you confirm this is actually working now?

Yes, after using the username:API-token method I am able to trigger the jenkins job from JIRA Automation.

 

Thanks!

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 7, 2021

@mayank goyal 

In case you cannot find much in Jenkins logs, another thing you can do is the following:

  1. Create a mock endpoint using something like https://requestbin.com/ or https://beeceptor.com/
  2. Roll-back the automation rule as it when it was failing and replace the endpoint url to be called with the one generated in above step (or just create a copy of the rule, so that you can confirm the request still fails in Jenkins)
  3. Trigger the automation rule
  4. Send the same request against the same endpoint created in step #1 using Talend API tester
  5. Go back to requestbin or beeceptor and check what's different among the 2 requests

 

I hope this helps

 

Cheers,
Dario

charleslcso October 30, 2021

Hello

Hope I'm not hijacking this thread.

@Dario B I'm not as lucky as @mayank goyal .

I followed your 4 steps posted at Jul 06, 2021, I can't get Automation to work. 

First of all, command line curl works as expected. Jenkins job will be triggered.

curl -X POST -L --user charles:110c243XXXX195249b3a46517a0cf12822 'https://jenkins.xxxxxx.com/job/Xray%20project/build'

 

I don't know the correct way to use Headers.

Here is what I'm using. 

Screen Shot 2021-10-30 at 3.22.17 PM.jpg

 

 

Jenkins' log says I need to use Crumb.... strange.

charleslcso November 1, 2021

Never mind... it is working now.

Like Dario B likes this
Sam Nittala November 16, 2021

How did you manage to @charleslcso

Like Chana likes this
heidi.rechek April 14, 2023

@charleslcso I am trying to setup a similar automation and would really like to know how you "got it working". 

Like Chana likes this
Chana August 31, 2023

@charleslcso How did you manage to

0 votes
Mark Rekveld - Marvelution
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 31, 2023

For those this looking, the Jenkins Integration for Jira app supports triggering a build via a manual issue action as well as via a Workflow Post Function. Check out the docs here: https://jjc.marvelution.com/docs/features/trigger-build

0 votes
gnanavelu_murthy March 10, 2022

@Dario B  @mayank goyal and @charleslcso 

I am also not able configure this automation webhook fires 503 error. Dont know where i missed. 

Server: squid

Mime-Version: 1.0

Date: Thu, 10 Mar 2022 20:03:36 GMT

Content-Type: text/html;charset=utf-8

Content-Length: 3261

X-Squid-Error: ERR_DNS_FAIL 0

Vary: Accept-Language

Content-Language: en

webhook.PNG

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 11, 2022

The error you get is "service unavailable" and therefore this doesn't seem to be authentication related.

Actually, the error returned by squid is DNS related: 

ERR_DNS_FAIL

 

Are you actually able to send the same request using Curl? 

karthik.c May 31, 2022

@gnanavelu_murthy @Dario B 

We tried from Postman and able to trigger build in jenkins. Getting error only when triggered from JIRA Cloud site.

Capture.PNG

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 31, 2022

Not providing any detail about what does not work is not helping us to help you ;) 

However, as a starting point, you may want to check the error message returned by Jenkins. 

gnanavelu_murthy May 31, 2022

Thanks for your reply @Dario B 

This thread was continue of mine - trying to configure JIRA cloud site - using automation webhook option - to trigger jenkins build based on jira ticket status change or update.

It fires the following squied error - 503 error. 

Server: squid

Mime-Version: 1.0

Date: Thu, 10 Mar 2022 20:03:36 GMT

Content-Type: text/html;charset=utf-8

Content-Length: 3261

X-Squid-Error: ERR_DNS_FAIL 0

Vary: Accept-Language

Content-Language: en

 our developer @karthik.c  tries using postman api tool to verify able to trigger our jenkins build. What need to be addressed to achieve this jenkins build trigger from jira ticket.

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 31, 2022

@gnanavelu_murthy @karthik.c 

 

As already written on the 11th of March the error you are getting is a DNS fail:

Actually, the error returned by squid is DNS related: 

ERR_DNS_FAIL

 

And indeed, it looks like your Jenkins site is not reachable from the Internet:

phoenix.olamnet.com: Name or service not known

 

Not even the domain olamnet.com is actually translating to an IP address and therefore it's not reachable form the Internet: 

 

 

Most likely you are able to connect using POSTMAN because you use either a VPN or a proxy that allows you to connect to that URL from your computer, but in order to be accessible from your Cloud site your Jenkins installation has to be reachable from the Internet using https (please notice: self-signed certificates are not accepted).

Like Shinde_ Mukund likes this
Anonymous Coward May 31, 2022

Simon says:

' @gnanavelu_murthy the host phoenix.olamnet.com is known only in your kitchen. Let the global DNS know about it first. '

https://mxtoolbox.com/SuperTool.aspx?action=a%3aphoenix.olamnet.com&run=toolpage

Simon out.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events