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

BAMBOO task to use Token based authentication in the CURL script to create JIRA ticket

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2024

Hi Team,

I want to create JIRA ticket using the below CRL script by executing form Bamboo task. When we using basic authentication credentials in curl like below, it is creating JIRA ticket fine.

Basic Authentication script, this is working fine.

curl -D- -u abcd:test1234 -X POST --data "{\"fields\":{\"project\": {\"key\": \"HELLOWS\" }, \"summary\": \"${bamboo.planName} - ${bamboo.buildNumber}\", \"customfield_11601\": \"${bamboo.planKey}-${bamboo.buildNumber}\", \"customfield_11600\": \"${bamboo.proj.pom.releaseVersion}\n\", \"description\": \"Link to the build:\n${bamboo.resultsUrl}\n Link to UAT Deployment logs:\n https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSUAT/deployments \n Link to PROD Deployment logs:\n https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSPROD/deployments \n \",\"issuetype\": {\"name\": \"Task\"}}}" -H "Content-Type: application/json" -k https://jira-uat.appD.appZ.com/rest/api/2/issue/

Output: I can see JIRA new ticket created.

 

But , when I am trying to use Token based authentication in the CURL script, it gives bad substitution error and it is taking other JIRA project key(AUTJT), where I actually trying to create for the JIRA project key "HELLOWS". 

 

CURL Script is:-

curl -D- -u "Authorization: Bearer +ZZx2sJona6Cqeo37KjfvRv" -X POST --data "{\"fields\":{\"project\": {\"key\": \"HELLOWS\" }, \"summary\": \"${bamboo.planName} - ${bamboo.buildNumber}\", \"customfield_11601\": \"${bamboo.planKey}-${bamboo.buildNumber}\", \"customfield_11600\": \"${bamboo.proj.pom.releaseVersion}\n\", \"description\": \"Link to the build:\n${bamboo.resultsUrl}\n Link to UAT Deployment logs:\n
https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSUAT/deployments
\n Link to PROD Deployment logs:\n
https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSPROD/deployments
\n \",\"issuetype\": {\"name\": \"Task\"}}}" -H "Content-Type: application/json" -k
https://jira-uat.appD.appZ.com/rest/api/2/issue/


output:
/bamboo/application-data/temp/RT-AUTJT-JOB1-35-ScriptBuildTask-6485507220746562543.sh: line 1: {"fields":{"project": {"key": "HELLOWS" }, "summary": "Retail Transformation - AutoJIRATicketPlan - 35", "customfield_11601": "RT-AUTJT-35", "customfield_11600": "${bamboo.proj.pom.releaseVersion}\n", "description": "Link to the build:\n
https://bamboo-uat.appD.appZ.com/browse/RT-AUTJT-JOB1-35\n
Link to UAT Deployment logs:\n
https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSUAT/deployments
\n Link to PROD Deployment logs:\n
https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSPROD/deployments
\n ","issuetype": {"name": "Task"}}}: bad substitution

 

Now, please help me, how to create the JIRA ticket using the token based authentication in the CURL, and also, form where it is referring the other project key? 

 

 

 

 

Thanks,

Dev G

 

1 answer

2 votes
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2024

Hello Dev G,

Welcome to Atlassian community

I think you are using -u for both user_id password & PAT token based authentication, the API will not differ based on what authentication type you are choosing.

For using PAT Tokens you can use an example like this, refer PAT Tokens 

curl -H "Authorization: Bearer NDc4NDkyNDg3ODE3OstHYSeYC1UgXqRacSqvUbookcZk" http://localhost:8085/bamboo/rest/api/latest/plan/PROJ-PLAN 

Regards,

Shashank Kumar

**please don't forget to Accept the answer if your query was answered**

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events