Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Trigger Jenkins builds using Jira Automation Edited

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

1 answer

1 accepted

1 vote
Answer accepted
Dario B Atlassian Team Jul 06, 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

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 Jul 07, 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?

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 Jul 07, 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

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 Jul 07, 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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
Community showcase
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

87 views 0 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you