-
Notifications
You must be signed in to change notification settings - Fork 9
/
jira.yaml
158 lines (144 loc) · 5.65 KB
/
jira.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
systems:
jira:
description: |
This system enables Honeydipper to integrate with `jira`, so Honeydipper can
react to jira events and take actions on jira.
meta:
configurations:
- name: jira_credential
description: The credential used for making API calls to `jira`
- name: token
description: >
A token used for authenticate incoming webhook requests, every webhook request
must carry a form field **Token** in the post body or url query that matches the value
- name: path
description: The path portion of the webhook url, by default :code:`/jira`
- name: jira_domain
description: Specify the jira domain, e.g. :code:`mycompany` for :code:`mycompany.atlassian.net`
- name: jira_domain_base
description: The DNS zone of the jira API urls, in case of accessing self hosted jira, defaults to :code:`atlassian.net`
notes:
- For example
- example: |
---
systems:
github:
data:
jira_credential: ENC[gcloud-kms,...masked...]
jira_domain: mycompany
token: ENC[gcloud-kms,...masked...]
path: "/webhook/jira"
- Assuming the domain name for the webhook server is :code:`myhoneydipper.com', you should
configure the webhook in your repo with url like below
- |
.. code-block::
https://myhoneydipper.com/webhook/jira?token=...masked...
data:
token: _place_holder_
path: "/jira"
jira_domain: _place_holder_
jira_credentials: _place_holder_
jira_domain_base: atlassian.net
functions:
createTicket:
driver: web
rawAction: request
parameters:
method: POST
URL: https://{{ .sysData.jira_domain }}.{{ .sysData.jira_domain_base }}/rest/api/2/issue/
header:
Authorization: Basic {{ .sysData.jira_credentials }}
Accept: application/json
Content-Type: application/json; charset=utf-8
content:
fields: $ctx.ticket
export_on_success:
jira_ticket: $data.json.key
links:
jira_ticket:
text: See ticket {{ .data.json.key }} in JIRA
url: https://{{ .sysData.jira_domain }}.{{ .sysData.jira_domain_base }}/browse/{{ .data.json.key }}
description: >
This function will create a jira ticket with given information, refer to
`jira rest API document<https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post>`_
for description of the fields and custom fields.
meta:
inputs:
- name: ticket.project.key
description: The name of the jira project the ticket is created in
- name: ticket.summary
description: A summary of the ticket
- name: ticket.description
description: Detailed description of the work for this ticket
- name: ticket.issuetype.name
description: The ticket type
- name: ticket.components
description: Optional, a list of components associated with the ticket
- name: ticket.labels
description: Optional, a list of strings used as labels
exports:
- name: jira_ticket
description: The ticket number of the newly created ticket
notes:
- See below for example
- example: |
---
workflows:
create_jira_ticket:
call_function: jira.createTicket
with:
ticket:
project:
key: devops
issuetype:
name: Task
summary: upgrading kubernetes
description: |
Upgrade the test cluster to kubernetes 1.16
components:
- name: GKE
- name: security
labels:
- toil
- small
addComment:
driver: web
rawAction: request
parameters:
method: POST
URL: https://{{ .sysData.jira_domain }}.{{ .sysData.jira_domain_base }}/rest/api/2/issue/{{ .ctx.jira_ticket }}/comment
header:
Authorization: Basic {{ .sysData.jira_credentials }}
Accept: application/json
Content-Type: application/json; charset=utf-8
content:
body: $ctx.comment_body
description: >
This function will add a comment to the jira ticket
meta:
inputs:
- name: jira_ticket
description: The ticket number that the comment is for
- name: comment_body
description: Detailed description of the comment
notes:
- See below for example
- example: |
---
workflows:
post_comments:
call_function: jira.addComment
with:
jira_ticket: $ctx.jira_ticket
comment_body: |
Ticket has been created by Honeydipper.
triggers:
hit:
driver: webhook
if_match:
method: POST
form:
token: $sysData.token
url: $sysData.path
description: This is a generic trigger for jira webhook events.