forked from linux-system-roles/auto-maintenance
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
- name: List issues | ||
hosts: localhost | ||
gather_facts: false | ||
vars: | ||
config_file: "{{ lookup('env', 'HOME') ~ '/.config/jira.yml' }}" | ||
config: "{{ lookup('file', config_file) | from_yaml }}" | ||
current: "{{ config['current'] }}" | ||
url: "{{ config[current]['url'] }}" | ||
token: "{{ config[current]['token'] }}" | ||
project: "{{ config[current]['project'] }}" | ||
component: "{{ config[current]['component'] }}" | ||
product: "{{ config[current]['product'] }}" | ||
pool_team: "{{ config[current]['pool_team'] }}" | ||
itr_query_field: fixVersion | ||
itr: "{{ lookup('env', 'ITR') if lookup('env', 'ITR') | length > 0 else 'rhel-9.4.0' }}" | ||
status_query_field: status | ||
module_defaults: | ||
community.general.jira: | ||
project: "{{ project }}" | ||
token: "{{ token }}" | ||
uri: "{{ url }}" | ||
tasks: | ||
- name: Get issues matching criteria | ||
community.general.jira: | ||
operation: search | ||
jql: component = {{ component }} AND "{{ itr_query_field }}" = {{ itr }} AND "{{ status_query_field }}" = "{{ status }}" | ||
args: | ||
fields: | ||
summary: | ||
customfield_12318450: # Fixed In Build | ||
register: issues # issues.meta.issues | ||
|
||
- name: List issues | ||
copy: | ||
content: |- | ||
{% for issue in issues.meta.issues %} | ||
{{ issue.key }} {{ issue.fields.customfield_12318450 }} {{ issue.fields.summary }} | ||
{% endfor %} | ||
dest: "{{ output_file | d('issues') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
- name: Use the Request Clones feature to clone a given issue | ||
hosts: localhost | ||
gather_facts: false | ||
vars: | ||
config_file: "{{ lookup('env', 'HOME') ~ '/.config/jira.yml' }}" | ||
config: "{{ lookup('file', config_file) | from_yaml }}" | ||
current: "{{ config['current'] }}" | ||
url: "{{ config[current]['url'] }}" | ||
token: "{{ config[current]['token'] }}" | ||
project: "{{ config[current]['project'] }}" | ||
component: "{{ config[current]['component'] }}" | ||
product: "{{ config[current]['product'] }}" | ||
pool_team: "{{ config[current]['pool_team'] }}" | ||
module_defaults: | ||
community.general.jira: | ||
project: "{{ project }}" | ||
token: "{{ token }}" | ||
uri: "{{ url }}" | ||
tasks: | ||
- name: Set update issue key | ||
set_fact: | ||
update_issue_key: "{{ clone_issue_key }}" | ||
|
||
- name: Request clone | ||
include_tasks: tasks/update_issue.yml | ||
|
||
- name: Get issue to clone | ||
community.general.jira: | ||
operation: fetch | ||
issue: "{{ clone_issue_key }}" | ||
register: clone_issue | ||
until: clone_issue.meta.fields.issuelinks | selectattr('type.inward', 'match', 'is cloned by') | length > 0 | ||
|
||
- name: Debug | ||
debug: | ||
msg: links {{ clone_issue.meta.fields.issuelinks | selectattr('type.inward', 'match', 'is cloned by') | list | to_nice_json }} | ||
|
||
- name: Wait until new issue points to cloned issue | ||
community.general.jira: | ||
operation: fetch | ||
issue: "{{ new_issue_key }}" | ||
register: new_issue | ||
until: new_issue.meta.fields.issuelinks | selectattr("outwardIssue.key", "match", clone_issue_key) | length > 0 | ||
vars: | ||
new_issue_key: "{{ clone_issue.meta.fields.issuelinks | selectattr('type.inward', 'match', 'is cloned by') | | ||
selectattr('inwardIssue', 'defined') | map(attribute='inwardIssue.key') | first }}" | ||
|
||
# many of the fields are copied by the request clone process | ||
# other fields are updated accordingly e.g. fixVersion is set correctly | ||
- name: Set vars for creating the clone | ||
set_fact: | ||
doc_text: "{{ clone_issue.meta.fields.customfield_12317313 | d('') }}" | ||
doc_text_type: "{{ clone_issue.meta.fields.customfield_12320850.value | d('') }}" | ||
docs_impact: "{{ clone_issue.meta.fields.customfield_12324040.value | d('') }}" | ||
dev_ack: "{{ 'Dev ack' if clone_issue.meta.fields.customfield_12317366 | | ||
selectattr('value', 'eq', 'Dev ack') | length > 0 else '' }}" | ||
qa_ack: "{{ 'QE ack' if clone_issue.meta.fields.customfield_12317366 | | ||
selectattr('value', 'eq', 'QE ack') | length > 0 else '' }}" | ||
itm: "{{ clone_issue.meta.fields.customfield_12321040.value | d('') | string }}" | ||
dtm: "{{ clone_issue.meta.fields.customfield_12318141.value | d('') | string }}" | ||
sprint: "{{ __sprint_id | string }}" | ||
status: "{{ clone_issue.meta.fields.status.name }}" | ||
story_points: "{{ '%f' | format(clone_issue.meta.fields.customfield_12310243 | d(0.0)) | string }}" | ||
preliminary_testing: "{{ clone_issue.meta.fields.customfield_12321540.value | d('') }}" | ||
update_issue_key: "{{ new_issue.meta.key }}" | ||
vars: | ||
__pat: >- | ||
^.*\[id=(\d+),.*$ | ||
__sprint_id: "{{ clone_issue.meta.fields.customfield_12310940 | d(['']) | | ||
map('regex_replace', __pat, '\\1') | first }}" | ||
|
||
- name: Update new issue | ||
include_tasks: tasks/update_issue.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters