Why is my previously working script for creating Jira Ticket using Ansible not working anymore?

Azeus System Team February 11, 2018

I created a .yml script for ansible about 2 weeks ago for creating a Jira Ticket. The ticket uses custom fields. Some of the custom fields have drop-down list choices. The script was working before but now it returns HTTP Error 400: Bad Request. I tried removing the custom fields with drop-down list choices and it worked. The syntax I used previously  for the drop-down list custom fields was this:

args:
  fields:
    customfield_XXXXX:
      value: '{{foo.stdout}}'

I swear I was able to create tickets weeks ago. Did jira change something or is ther something I'm missing?

4 answers

1 accepted

0 votes
Answer accepted
Azeus System Team February 19, 2018

My script works now. Apparently, the correct syntax for custom fields is this:

args:
  fields:
    customfield_XXXXX: {
      "self": "http://domain.com:port/rest/api/2/customFieldOption/customfieldid",
      "value": "customfieldvalue",
      "id": "customfieldid"
    }

 

Anyway, thank you guys for the answers and suggestions.

1 vote
Alexey Matveev
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 11, 2018

It looks to me that your json is not valid. At least it must be like this:

args:
  fields:
    customfield_XXXXX: {
      value: '{{foo.stdout}}'}

0 votes
yugendran August 20, 2019

Hi 

Any help on this greatly appreciated.

Actually i am new to this, I am writing an yaml file to create JIRA ticket through ansible.

I have the script to connect to JIRA, But i got the error 

"Skipping no hosts matched" on execution.

this is the script i have:

also if possible anyone can share me a working sample script to create jira ticket

---
- hosts: "{{host_name}}"
remote_user: "{{run_user}}"
vars_prompt:
- name: user name
prompt: "Enter the username"
private: no
- name: password
prompt: "Enter the password"
tasks:
- name: connecting to jira
uri:
url: https://jira.global.xxxxxx.com
user: '{{user name}}'
password: '{{password}}'
method: GET
return_content: yes
status_code: 200
register: Status
- debug:
var: Status.stdout_lines

0 votes
Danyal Iqbal
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 12, 2018

HTTP Error 400: Bad Request means your json is incorrect. You need to check the detailed message in the response to find out what exactly is wrong with your json.

Your json probably contains customfields which are not present on the create screen for the issuetype you want to create.

Suggest an answer

Log in or Sign up to answer