jirabatch 0.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jirabatch-0.10.0/LICENSE +201 -0
- jirabatch-0.10.0/PKG-INFO +140 -0
- jirabatch-0.10.0/README.md +111 -0
- jirabatch-0.10.0/jirabatch/__init__.py +59 -0
- jirabatch-0.10.0/jirabatch/atlas.py +353 -0
- jirabatch-0.10.0/jirabatch/logger.py +24 -0
- jirabatch-0.10.0/pyproject.toml +55 -0
jirabatch-0.10.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025-2026 Cliffano Subagio
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jirabatch
|
|
3
|
+
Version: 0.10.0
|
|
4
|
+
Summary: Create Jira tickets via YAML
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: jirabatch,jira,issues
|
|
8
|
+
Author: Cliffano Subagio
|
|
9
|
+
Author-email: cliffano@gmail.com
|
|
10
|
+
Requires-Python: >=3.10,<4.0
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Dist: PyYAML (>=6.0.3,<6.1.0)
|
|
20
|
+
Requires-Dist: cfgrw (>=1.1.0,<1.2.0)
|
|
21
|
+
Requires-Dist: click (>=8.3.3,<8.4.0)
|
|
22
|
+
Requires-Dist: conflog (>=2.1.1,<2.2.0)
|
|
23
|
+
Requires-Dist: jira (>=3.10.5,<3.11.0)
|
|
24
|
+
Project-URL: Documentation, https://github.com/cliffano/jirabatch
|
|
25
|
+
Project-URL: Homepage, https://github.com/cliffano/jirabatch
|
|
26
|
+
Project-URL: Repository, https://github.com/cliffano/jirabatch
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
[](https://github.com/cliffano/jirabatch/actions?query=workflow%3ACI)
|
|
32
|
+
[](https://snyk.io/test/github/cliffano/jirabatch)
|
|
33
|
+
[](https://libraries.io/github/cliffano/jirabatch)
|
|
34
|
+
[](https://pypi.python.org/pypi/jirabatch)
|
|
35
|
+
|
|
36
|
+
# JiraBatch
|
|
37
|
+
|
|
38
|
+
Jira Batch is a batch Jira issues creator.
|
|
39
|
+
|
|
40
|
+
Define the issues in
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
pip3 install jirabatch
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
Create a configuration file, e.g. `jirabatch.yaml`, and then create an issues file, e.g. `issues.yaml` .
|
|
49
|
+
|
|
50
|
+
Run jirabatch with specified config file and issues file:
|
|
51
|
+
|
|
52
|
+
jirabatch --conf-file jirabatch.yaml --issues-file issues.yaml
|
|
53
|
+
|
|
54
|
+
Show help guide:
|
|
55
|
+
|
|
56
|
+
jirabatch --help
|
|
57
|
+
|
|
58
|
+
## Configuration
|
|
59
|
+
|
|
60
|
+
These are the configuration properties that you can use with `jirabatch` CLI.
|
|
61
|
+
Some example configuration files are available on [examples](examples) folder.
|
|
62
|
+
|
|
63
|
+
Jira Batch configuration properties:
|
|
64
|
+
|
|
65
|
+
| Property | Type | Required | Description | Example |
|
|
66
|
+
|----------|------|----------|-------------|---------|
|
|
67
|
+
| `url` | String | Yes | The base URL of the Jira server | `https://someorg.atlassian.net` |
|
|
68
|
+
| `user` | String | Yes | The Jira username or email address | `someuser@example.com` |
|
|
69
|
+
| `api_token` | String | Yes* | The Jira API token used for authentication. Takes precedence over `password` | `sometoken12345` |
|
|
70
|
+
| `password` | String | Yes* | The Jira account password. Used as fallback when `api_token` is not set | `somepassword` |
|
|
71
|
+
|
|
72
|
+
Issues configuration properties:
|
|
73
|
+
|
|
74
|
+
| Property | Type | Required | Description | Example |
|
|
75
|
+
|----------|------|----------|-------------|---------|
|
|
76
|
+
| `defaults` | Object | No | Default field values merged into every entry in `issues[]` | `{ project: "KAN", issuetype: "Task" }` |
|
|
77
|
+
| `issues[]` | Array | Yes | List of Jira issues to create | `[{ summary: "Issue summary" }]` |
|
|
78
|
+
| `issues[].project` | String | Yes* | Jira project key | `ENG` |
|
|
79
|
+
| `issues[].issuetype` | String | Yes* | Jira issue type name | `Task` |
|
|
80
|
+
| `issues[].summary` | String | Yes* | Jira issue summary | `Rotate SSH key` |
|
|
81
|
+
| `issues[].description` | String | No | Jira issue description | `Rotate SSH key before expiry` |
|
|
82
|
+
| `issues[].reporter` | String | No | Reporter account ID | `5b10a2844c20165700ede21g` |
|
|
83
|
+
| `issues[].assignee` | String | No | Assignee account ID | `5b10ac8d82e05b22cc7d4ef5` |
|
|
84
|
+
| `issues[].priority` | String | No | Priority name | `High` |
|
|
85
|
+
| `issues[].labels[]` | Array[String] | No | Labels to assign | `["infra", "security"]` |
|
|
86
|
+
| `issues[].components[]` | Array[String] | No | Component names | `["Cloud", "Backend"]` |
|
|
87
|
+
| `issues[].versions[]` | Array[String] | No | Affects version names | `["2026.1"]` |
|
|
88
|
+
| `issues[].fixVersions[]` | Array[String] | No | Fix version names | `["2026.2"]` |
|
|
89
|
+
| `issues[].environment` | String | No | Environment field value | `Production AWS us-east-1` |
|
|
90
|
+
| `issues[].duedate` | String | No | Due date (sent as string) | `2026-04-01` |
|
|
91
|
+
| `issues[].timetracking` | Object | No | Jira timetracking object | `{ originalEstimate: "3d", remainingEstimate: "2d" }` |
|
|
92
|
+
| `issues[].security` | String | No | Security level name | `Internal` |
|
|
93
|
+
| `issues[].parent` | String | No | Parent issue key | `KAN-100` |
|
|
94
|
+
| `issues[].epic` | String | No | Epic issue key (normalized to parent) | `KAN-10` |
|
|
95
|
+
| `issues[].customFields` | Object | No | Map of Jira custom field IDs to values | `{ customfield_10100: "Platform Team" }` |
|
|
96
|
+
| `issues[].subtasks[]` | Array[Object] | No | Subtasks created after parent issue succeeds | `[{ summary: "Subtask 1" }]` |
|
|
97
|
+
| `issues[].subtasks[].summary` | String | Yes | Subtask summary | `Update cert in service A` |
|
|
98
|
+
| `issues[].subtasks[].issuetype` | String | No | Subtask issue type (defaults to `Subtask`) | `Sub-task` |
|
|
99
|
+
|
|
100
|
+
## FAQ
|
|
101
|
+
|
|
102
|
+
*How to find reporter and assignee values?*
|
|
103
|
+
|
|
104
|
+
`reporter` and `assignee` must be Jira `accountId` values, not display names or email addresses.
|
|
105
|
+
|
|
106
|
+
Visit `https://<id>.atlassian.net/rest/api/3/user/search?query=<user_name_or_email>`
|
|
107
|
+
and you will receive a JSON response:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
[
|
|
111
|
+
{
|
|
112
|
+
"accountId": "5b10a2844c20165700ede21g",
|
|
113
|
+
"displayName": "Some User",
|
|
114
|
+
...
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Copy the `accountId` value and use it in your issues file:
|
|
120
|
+
|
|
121
|
+
```yaml
|
|
122
|
+
issues:
|
|
123
|
+
- summary: Some Jira issue
|
|
124
|
+
reporter: "5b10a2844c20165700ede21g"
|
|
125
|
+
assignee: "5b10a2844c20165700ede21g"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Colophon
|
|
129
|
+
|
|
130
|
+
[Developer's Guide](https://cliffano.github.io/developers_guide.html#python)
|
|
131
|
+
|
|
132
|
+
Build reports:
|
|
133
|
+
|
|
134
|
+
* [Lint report](https://cliffano.github.io/jirabatch/lint/pylint/index.html)
|
|
135
|
+
* [Code complexity report](https://cliffano.github.io/jirabatch/complexity/wily/index.html)
|
|
136
|
+
* [Unit tests report](https://cliffano.github.io/jirabatch/test/pytest/index.html)
|
|
137
|
+
* [Test coverage report](https://cliffano.github.io/jirabatch/coverage/coverage/index.html)
|
|
138
|
+
* [Integration tests report](https://cliffano.github.io/jirabatch/test-integration/pytest/index.html)
|
|
139
|
+
* [API Documentation](https://cliffano.github.io/jirabatch/doc/sphinx/index.html)
|
|
140
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://github.com/cliffano/jirabatch/actions?query=workflow%3ACI)
|
|
4
|
+
[](https://snyk.io/test/github/cliffano/jirabatch)
|
|
5
|
+
[](https://libraries.io/github/cliffano/jirabatch)
|
|
6
|
+
[](https://pypi.python.org/pypi/jirabatch)
|
|
7
|
+
|
|
8
|
+
# JiraBatch
|
|
9
|
+
|
|
10
|
+
Jira Batch is a batch Jira issues creator.
|
|
11
|
+
|
|
12
|
+
Define the issues in
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
pip3 install jirabatch
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Create a configuration file, e.g. `jirabatch.yaml`, and then create an issues file, e.g. `issues.yaml` .
|
|
21
|
+
|
|
22
|
+
Run jirabatch with specified config file and issues file:
|
|
23
|
+
|
|
24
|
+
jirabatch --conf-file jirabatch.yaml --issues-file issues.yaml
|
|
25
|
+
|
|
26
|
+
Show help guide:
|
|
27
|
+
|
|
28
|
+
jirabatch --help
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
These are the configuration properties that you can use with `jirabatch` CLI.
|
|
33
|
+
Some example configuration files are available on [examples](examples) folder.
|
|
34
|
+
|
|
35
|
+
Jira Batch configuration properties:
|
|
36
|
+
|
|
37
|
+
| Property | Type | Required | Description | Example |
|
|
38
|
+
|----------|------|----------|-------------|---------|
|
|
39
|
+
| `url` | String | Yes | The base URL of the Jira server | `https://someorg.atlassian.net` |
|
|
40
|
+
| `user` | String | Yes | The Jira username or email address | `someuser@example.com` |
|
|
41
|
+
| `api_token` | String | Yes* | The Jira API token used for authentication. Takes precedence over `password` | `sometoken12345` |
|
|
42
|
+
| `password` | String | Yes* | The Jira account password. Used as fallback when `api_token` is not set | `somepassword` |
|
|
43
|
+
|
|
44
|
+
Issues configuration properties:
|
|
45
|
+
|
|
46
|
+
| Property | Type | Required | Description | Example |
|
|
47
|
+
|----------|------|----------|-------------|---------|
|
|
48
|
+
| `defaults` | Object | No | Default field values merged into every entry in `issues[]` | `{ project: "KAN", issuetype: "Task" }` |
|
|
49
|
+
| `issues[]` | Array | Yes | List of Jira issues to create | `[{ summary: "Issue summary" }]` |
|
|
50
|
+
| `issues[].project` | String | Yes* | Jira project key | `ENG` |
|
|
51
|
+
| `issues[].issuetype` | String | Yes* | Jira issue type name | `Task` |
|
|
52
|
+
| `issues[].summary` | String | Yes* | Jira issue summary | `Rotate SSH key` |
|
|
53
|
+
| `issues[].description` | String | No | Jira issue description | `Rotate SSH key before expiry` |
|
|
54
|
+
| `issues[].reporter` | String | No | Reporter account ID | `5b10a2844c20165700ede21g` |
|
|
55
|
+
| `issues[].assignee` | String | No | Assignee account ID | `5b10ac8d82e05b22cc7d4ef5` |
|
|
56
|
+
| `issues[].priority` | String | No | Priority name | `High` |
|
|
57
|
+
| `issues[].labels[]` | Array[String] | No | Labels to assign | `["infra", "security"]` |
|
|
58
|
+
| `issues[].components[]` | Array[String] | No | Component names | `["Cloud", "Backend"]` |
|
|
59
|
+
| `issues[].versions[]` | Array[String] | No | Affects version names | `["2026.1"]` |
|
|
60
|
+
| `issues[].fixVersions[]` | Array[String] | No | Fix version names | `["2026.2"]` |
|
|
61
|
+
| `issues[].environment` | String | No | Environment field value | `Production AWS us-east-1` |
|
|
62
|
+
| `issues[].duedate` | String | No | Due date (sent as string) | `2026-04-01` |
|
|
63
|
+
| `issues[].timetracking` | Object | No | Jira timetracking object | `{ originalEstimate: "3d", remainingEstimate: "2d" }` |
|
|
64
|
+
| `issues[].security` | String | No | Security level name | `Internal` |
|
|
65
|
+
| `issues[].parent` | String | No | Parent issue key | `KAN-100` |
|
|
66
|
+
| `issues[].epic` | String | No | Epic issue key (normalized to parent) | `KAN-10` |
|
|
67
|
+
| `issues[].customFields` | Object | No | Map of Jira custom field IDs to values | `{ customfield_10100: "Platform Team" }` |
|
|
68
|
+
| `issues[].subtasks[]` | Array[Object] | No | Subtasks created after parent issue succeeds | `[{ summary: "Subtask 1" }]` |
|
|
69
|
+
| `issues[].subtasks[].summary` | String | Yes | Subtask summary | `Update cert in service A` |
|
|
70
|
+
| `issues[].subtasks[].issuetype` | String | No | Subtask issue type (defaults to `Subtask`) | `Sub-task` |
|
|
71
|
+
|
|
72
|
+
## FAQ
|
|
73
|
+
|
|
74
|
+
*How to find reporter and assignee values?*
|
|
75
|
+
|
|
76
|
+
`reporter` and `assignee` must be Jira `accountId` values, not display names or email addresses.
|
|
77
|
+
|
|
78
|
+
Visit `https://<id>.atlassian.net/rest/api/3/user/search?query=<user_name_or_email>`
|
|
79
|
+
and you will receive a JSON response:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
[
|
|
83
|
+
{
|
|
84
|
+
"accountId": "5b10a2844c20165700ede21g",
|
|
85
|
+
"displayName": "Some User",
|
|
86
|
+
...
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Copy the `accountId` value and use it in your issues file:
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
issues:
|
|
95
|
+
- summary: Some Jira issue
|
|
96
|
+
reporter: "5b10a2844c20165700ede21g"
|
|
97
|
+
assignee: "5b10a2844c20165700ede21g"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Colophon
|
|
101
|
+
|
|
102
|
+
[Developer's Guide](https://cliffano.github.io/developers_guide.html#python)
|
|
103
|
+
|
|
104
|
+
Build reports:
|
|
105
|
+
|
|
106
|
+
* [Lint report](https://cliffano.github.io/jirabatch/lint/pylint/index.html)
|
|
107
|
+
* [Code complexity report](https://cliffano.github.io/jirabatch/complexity/wily/index.html)
|
|
108
|
+
* [Unit tests report](https://cliffano.github.io/jirabatch/test/pytest/index.html)
|
|
109
|
+
* [Test coverage report](https://cliffano.github.io/jirabatch/coverage/coverage/index.html)
|
|
110
|
+
* [Integration tests report](https://cliffano.github.io/jirabatch/test-integration/pytest/index.html)
|
|
111
|
+
* [API Documentation](https://cliffano.github.io/jirabatch/doc/sphinx/index.html)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# pylint: disable=too-many-locals
|
|
2
|
+
"""
|
|
3
|
+
jirabatch
|
|
4
|
+
=======
|
|
5
|
+
... .
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
from cfgrw import CFGRW
|
|
10
|
+
from .atlas import Atlas
|
|
11
|
+
from .logger import init
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def create_jira_issues(conf_file: str, issues_file: str, batch_size: int) -> None:
|
|
15
|
+
"""Create Jira issues."""
|
|
16
|
+
|
|
17
|
+
logger = init()
|
|
18
|
+
|
|
19
|
+
logger.info(f"Loading configuration file {conf_file}")
|
|
20
|
+
conf_cfgrw = CFGRW(conf_file=conf_file)
|
|
21
|
+
conf = conf_cfgrw.read(["url", "user", "api_token"])
|
|
22
|
+
|
|
23
|
+
logger.info(f"Loading issues file {issues_file}")
|
|
24
|
+
issues_cfgrw = CFGRW(conf_file=issues_file)
|
|
25
|
+
issues = issues_cfgrw.read(["defaults", "issues"])
|
|
26
|
+
|
|
27
|
+
atlas = Atlas(conf=conf)
|
|
28
|
+
atlas.create_jira_issues(issues=issues, batch_size=batch_size)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@click.command()
|
|
32
|
+
@click.option(
|
|
33
|
+
"--conf-file",
|
|
34
|
+
default="jirabatch.yaml",
|
|
35
|
+
show_default=True,
|
|
36
|
+
type=str,
|
|
37
|
+
help="Configuration file path",
|
|
38
|
+
)
|
|
39
|
+
@click.option(
|
|
40
|
+
"--issues-file",
|
|
41
|
+
default="issues.yaml",
|
|
42
|
+
show_default=True,
|
|
43
|
+
type=str,
|
|
44
|
+
help="Issues file path",
|
|
45
|
+
)
|
|
46
|
+
@click.option(
|
|
47
|
+
"--batch-size",
|
|
48
|
+
default=50,
|
|
49
|
+
show_default=True,
|
|
50
|
+
type=int,
|
|
51
|
+
help="Maximum number of issues to be created in a single batch",
|
|
52
|
+
)
|
|
53
|
+
@click.version_option(package_name="jirabatch", prog_name="jirabatch")
|
|
54
|
+
def cli(conf_file: str, issues_file: str, batch_size: int) -> None:
|
|
55
|
+
"""Create multiple Jira issues.
|
|
56
|
+
Issue details are defined in the issues file,
|
|
57
|
+
while the Jira settings are defined in the config file.
|
|
58
|
+
"""
|
|
59
|
+
create_jira_issues(conf_file, issues_file, batch_size)
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# pylint: disable=too-many-locals,too-few-public-methods,too-many-branches
|
|
2
|
+
"""This module contains the Atlas class."""
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
from jira import JIRA
|
|
7
|
+
from jira.exceptions import JIRAError
|
|
8
|
+
from jira.utils import json_loads
|
|
9
|
+
from .logger import init
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Atlas:
|
|
13
|
+
"""This class represents an Atlassian Jira manager."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, conf: dict) -> None:
|
|
16
|
+
"""Initialize Atlas with a Jira connection.
|
|
17
|
+
|
|
18
|
+
Connects to the Jira server specified in ``conf`` using basic authentication.
|
|
19
|
+
``api_token`` is used as the credential when available, falling back to ``password``.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
conf: A configuration dictionary with the following keys:
|
|
23
|
+
|
|
24
|
+
- ``url``: The base URL of the Jira server.
|
|
25
|
+
- ``user``: The Jira username or email address.
|
|
26
|
+
- ``api_token``: The Jira API token (preferred).
|
|
27
|
+
Falls back to ``password`` if absent.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
self.logger = init()
|
|
31
|
+
self.jira = JIRA(
|
|
32
|
+
server=conf["url"],
|
|
33
|
+
basic_auth=(conf["user"], conf.get("api_token", conf.get("password"))),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def create_jira_issues(self, issues: dict, batch_size: int) -> None:
|
|
37
|
+
"""Create Jira issues in batches from a dictionary configuration.
|
|
38
|
+
|
|
39
|
+
Iterates through the provided issues dictionary, builds the field
|
|
40
|
+
definitions for each issue, and creates them in batches using the
|
|
41
|
+
Jira bulk creation API. Each batch is limited to
|
|
42
|
+
``batch_size`` issues to respect the Jira REST API limit.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
issues: A dictionary containing issue configurations. Expected
|
|
46
|
+
structure::
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
"issues": [
|
|
50
|
+
{
|
|
51
|
+
"project": str,
|
|
52
|
+
"summary": str,
|
|
53
|
+
"issuetype": str,
|
|
54
|
+
...
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
batch_size: Maximum number of issues to create per API call.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
# Get configured fields from issues file
|
|
63
|
+
default_fields = issues.get("defaults", {})
|
|
64
|
+
issues_fields = issues.get("issues", [])
|
|
65
|
+
|
|
66
|
+
# Construct a list of Jira field dicts for each issue, merging with defaults and
|
|
67
|
+
# extracting subtasks into a separate map to be processed after parent issues are created
|
|
68
|
+
jira_fields_list = []
|
|
69
|
+
subtask_map = {}
|
|
70
|
+
for index, issue_fields in enumerate(issues_fields):
|
|
71
|
+
combined_fields = {**default_fields, **issue_fields}
|
|
72
|
+
subtasks = combined_fields.pop("subtasks", None)
|
|
73
|
+
jira_fields_list.append(self._prepare_jira_fields(combined_fields))
|
|
74
|
+
if subtasks:
|
|
75
|
+
subtask_map[index] = subtasks
|
|
76
|
+
|
|
77
|
+
# Placeholder for any pending subtasks to be created
|
|
78
|
+
# after their parent issues are successfully created
|
|
79
|
+
pending_subtasks = []
|
|
80
|
+
|
|
81
|
+
for batch_start in range(0, len(jira_fields_list), batch_size):
|
|
82
|
+
|
|
83
|
+
batch = jira_fields_list[batch_start : batch_start + batch_size]
|
|
84
|
+
self.logger.info(f"Processing a batch of {len(batch)} issue(s)...")
|
|
85
|
+
|
|
86
|
+
api_results_list = self._bulk_create_issues(field_list=batch)
|
|
87
|
+
|
|
88
|
+
for batch_index, api_result in enumerate(api_results_list):
|
|
89
|
+
absolute_index = batch_start + batch_index
|
|
90
|
+
self.logger.debug(f"Result: {api_result}")
|
|
91
|
+
if api_result["status"] != "Success":
|
|
92
|
+
self._log_issue_creation_failure(api_result)
|
|
93
|
+
continue
|
|
94
|
+
|
|
95
|
+
created_issue = api_result["issue"]
|
|
96
|
+
self.logger.info(
|
|
97
|
+
"Created issue %s: %s",
|
|
98
|
+
created_issue.key,
|
|
99
|
+
created_issue.fields.summary,
|
|
100
|
+
)
|
|
101
|
+
self.logger.debug(
|
|
102
|
+
"Issue %s fields: %s",
|
|
103
|
+
created_issue.key,
|
|
104
|
+
api_result["input_fields"],
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
pending_subtasks.extend(
|
|
108
|
+
self._prepare_pending_subtasks(
|
|
109
|
+
subtasks=subtask_map.get(absolute_index, []),
|
|
110
|
+
default_fields=default_fields,
|
|
111
|
+
issue_fields=issues_fields[absolute_index],
|
|
112
|
+
parent_issue_key=created_issue.key,
|
|
113
|
+
)
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# Create any pending subtasks after all parent issues have been processed,
|
|
117
|
+
# so that subtasks of successfully created parent issues can be created while
|
|
118
|
+
# subtasks of failed parent issues are not attempted
|
|
119
|
+
if pending_subtasks:
|
|
120
|
+
self.logger.info(f"Creating {len(pending_subtasks)} subtask(s)...")
|
|
121
|
+
for batch_start in range(0, len(pending_subtasks), batch_size):
|
|
122
|
+
batch = pending_subtasks[batch_start : batch_start + batch_size]
|
|
123
|
+
self.logger.info(f"Processing a batch of {len(batch)} subtask(s)...")
|
|
124
|
+
api_results_list = self._bulk_create_issues(field_list=batch)
|
|
125
|
+
for api_result in api_results_list:
|
|
126
|
+
self.logger.debug(f"Result: {api_result}")
|
|
127
|
+
if api_result["status"] == "Success":
|
|
128
|
+
created_issue = api_result["issue"]
|
|
129
|
+
self.logger.info(
|
|
130
|
+
"Created subtask %s: %s",
|
|
131
|
+
created_issue.key,
|
|
132
|
+
created_issue.fields.summary,
|
|
133
|
+
)
|
|
134
|
+
else:
|
|
135
|
+
errors_str = self._format_errors(api_result)
|
|
136
|
+
fields_str = "\n".join(
|
|
137
|
+
f"- {key}: {value}"
|
|
138
|
+
for key, value in api_result["input_fields"].items()
|
|
139
|
+
)
|
|
140
|
+
self.logger.error(
|
|
141
|
+
"Failed to create subtask:\nErrors:\n%s\nFields:\n%s",
|
|
142
|
+
errors_str,
|
|
143
|
+
fields_str,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def _log_issue_creation_failure(self, api_result: dict) -> None:
|
|
147
|
+
"""Log issue creation failure details from a bulk API result."""
|
|
148
|
+
|
|
149
|
+
errors_str = self._format_errors(api_result)
|
|
150
|
+
fields_str = "\n".join(
|
|
151
|
+
f" {key}: {value}" for key, value in api_result["input_fields"].items()
|
|
152
|
+
)
|
|
153
|
+
self.logger.error(
|
|
154
|
+
"Failed to create issue:\nErrors:\n%s\nFields:\n%s",
|
|
155
|
+
errors_str,
|
|
156
|
+
fields_str,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
def _prepare_pending_subtasks(
|
|
160
|
+
self,
|
|
161
|
+
subtasks: list,
|
|
162
|
+
default_fields: dict,
|
|
163
|
+
issue_fields: dict,
|
|
164
|
+
parent_issue_key: str,
|
|
165
|
+
) -> list[dict]:
|
|
166
|
+
"""Prepare Jira field dicts for subtasks of a successfully created issue."""
|
|
167
|
+
|
|
168
|
+
if not subtasks:
|
|
169
|
+
return []
|
|
170
|
+
|
|
171
|
+
prepared_subtasks = []
|
|
172
|
+
for subtask in subtasks:
|
|
173
|
+
subtask_fields = {**default_fields, **subtask}
|
|
174
|
+
|
|
175
|
+
# Subtasks often omit project in YAML examples; inherit from
|
|
176
|
+
# the parent issue/defaults if none supplied in the subtask itself.
|
|
177
|
+
if "project" not in subtask_fields:
|
|
178
|
+
parent_project = issue_fields.get("project", default_fields.get("project"))
|
|
179
|
+
if parent_project:
|
|
180
|
+
subtask_fields["project"] = parent_project
|
|
181
|
+
|
|
182
|
+
subtask_fields["issuetype"] = subtask_fields.get("issuetype", "Subtask")
|
|
183
|
+
subtask_fields["parent"] = parent_issue_key
|
|
184
|
+
subtask_fields.pop("subtasks", None)
|
|
185
|
+
prepared_subtasks.append(self._prepare_jira_fields(subtask_fields))
|
|
186
|
+
|
|
187
|
+
return prepared_subtasks
|
|
188
|
+
|
|
189
|
+
def _bulk_create_issues(self, field_list: list[dict]) -> list[dict]:
|
|
190
|
+
"""Create issues via the Jira bulk API, capturing full error details.
|
|
191
|
+
|
|
192
|
+
Unlike ``JIRA.create_issues``, this method also captures
|
|
193
|
+
``errorMessages`` from the API response, not just field-level
|
|
194
|
+
``errors``.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
field_list: A list of Jira field dicts, one per issue.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
A list of result dicts with keys ``status``, ``issue``,
|
|
201
|
+
``error``, ``error_messages``, and ``input_fields``.
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
# Make API request to create issues in bulk, capturing
|
|
205
|
+
# both field-level errors and general error messages
|
|
206
|
+
api_request_payload = {
|
|
207
|
+
"issueUpdates": [{"fields": fields} for fields in field_list]
|
|
208
|
+
}
|
|
209
|
+
url = self.jira._get_url("issue/bulk") # pylint: disable=protected-access
|
|
210
|
+
try:
|
|
211
|
+
raw_api_response = (
|
|
212
|
+
self.jira._session.post( # pylint: disable=protected-access
|
|
213
|
+
url, data=json.dumps(api_request_payload)
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
api_response = json_loads(raw_api_response)
|
|
217
|
+
except JIRAError as je:
|
|
218
|
+
if je.status_code == 400 and je.response is not None:
|
|
219
|
+
api_response = json.loads(je.response.text)
|
|
220
|
+
else:
|
|
221
|
+
raise
|
|
222
|
+
errors = {}
|
|
223
|
+
for error in api_response.get("errors", []):
|
|
224
|
+
element_errors = error.get("elementErrors", {})
|
|
225
|
+
errors[error["failedElementNumber"]] = {
|
|
226
|
+
"errors": element_errors.get("errors", {}),
|
|
227
|
+
"errorMessages": element_errors.get("errorMessages", []),
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
# Build result list by pairing each input field with
|
|
231
|
+
# - (Success result) its created issue
|
|
232
|
+
# - (Error result) its error details
|
|
233
|
+
api_results_list = []
|
|
234
|
+
issues_queue = list(api_response.get("issues", []))
|
|
235
|
+
for index, fields in enumerate(field_list):
|
|
236
|
+
# Construct Error result
|
|
237
|
+
if index in errors:
|
|
238
|
+
api_results_list.append(
|
|
239
|
+
{
|
|
240
|
+
"status": "Error",
|
|
241
|
+
"error": errors[index]["errors"],
|
|
242
|
+
"error_messages": errors[index]["errorMessages"],
|
|
243
|
+
"issue": None,
|
|
244
|
+
"input_fields": fields,
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
# Construct Success result
|
|
248
|
+
else:
|
|
249
|
+
issue_raw = issues_queue.pop(0)
|
|
250
|
+
issue = self.jira.issue(issue_raw["key"])
|
|
251
|
+
api_results_list.append(
|
|
252
|
+
{
|
|
253
|
+
"status": "Success",
|
|
254
|
+
"issue": issue,
|
|
255
|
+
"error": None,
|
|
256
|
+
"error_messages": [],
|
|
257
|
+
"input_fields": fields,
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
return api_results_list
|
|
261
|
+
|
|
262
|
+
@staticmethod
|
|
263
|
+
def _format_errors(api_result: dict) -> str:
|
|
264
|
+
"""Format error details from a bulk create result into a readable string.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
api_result: A result dict from ``_bulk_create_issues``.
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
A formatted error string.
|
|
271
|
+
"""
|
|
272
|
+
lines = []
|
|
273
|
+
|
|
274
|
+
# Format error details from "error" field
|
|
275
|
+
error = api_result.get("error", {})
|
|
276
|
+
if error:
|
|
277
|
+
for field, msg in error.items():
|
|
278
|
+
lines.append(f"- {field}: {msg}")
|
|
279
|
+
|
|
280
|
+
# Format error details from "error_messages" field
|
|
281
|
+
for msg in api_result.get("error_messages", []):
|
|
282
|
+
lines.append(f"- {msg}")
|
|
283
|
+
|
|
284
|
+
# Add placeholder message when API result doesn't contain error-related field
|
|
285
|
+
if not lines:
|
|
286
|
+
lines.append("(no error details returned by Jira)")
|
|
287
|
+
|
|
288
|
+
return "\n".join(lines)
|
|
289
|
+
|
|
290
|
+
@staticmethod
|
|
291
|
+
def _prepare_jira_fields(config_fields: dict) -> dict:
|
|
292
|
+
"""Build a Jira-compatible issue fields dictionary from an issue configuration.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
config_fields: A dictionary describing a single issue with keys such as
|
|
296
|
+
``project``, ``summary``, ``issuetype``, and optional metadata.
|
|
297
|
+
|
|
298
|
+
Returns:
|
|
299
|
+
A dictionary of fields ready to be passed to the Jira API.
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
# Initialise Jira fields with required fields and common optional fields
|
|
303
|
+
jira_fields = {
|
|
304
|
+
"project": {"key": config_fields["project"]},
|
|
305
|
+
"issuetype": {"name": config_fields["issuetype"]},
|
|
306
|
+
"summary": config_fields["summary"],
|
|
307
|
+
"description": config_fields.get("description"),
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
# Add optional fields with AS-IS value
|
|
311
|
+
for field_name in ["labels", "environment", "timetracking"]:
|
|
312
|
+
if field_name in config_fields:
|
|
313
|
+
jira_fields[field_name] = config_fields[field_name]
|
|
314
|
+
|
|
315
|
+
# Add optional fields with stringified formatting
|
|
316
|
+
for field_name in ["duedate"]:
|
|
317
|
+
if field_name in config_fields:
|
|
318
|
+
jira_fields[field_name] = str(config_fields[field_name])
|
|
319
|
+
|
|
320
|
+
# Add optional fields that require nested formatting with "accountId" key
|
|
321
|
+
for field_name in ["reporter", "assignee"]:
|
|
322
|
+
if field_name in config_fields:
|
|
323
|
+
jira_fields[field_name] = {"accountId": config_fields[field_name]}
|
|
324
|
+
|
|
325
|
+
# Add optional parent reference with nested formatting using "key".
|
|
326
|
+
# `epic` is normalized to `parent` so downstream payload handling is consistent.
|
|
327
|
+
if "parent" in config_fields:
|
|
328
|
+
jira_fields["parent"] = {"key": config_fields["parent"]}
|
|
329
|
+
elif "epic" in config_fields:
|
|
330
|
+
jira_fields["parent"] = {"key": config_fields["epic"]}
|
|
331
|
+
|
|
332
|
+
# Add optional fields that require nested formatting with "name" key and AS-IS value
|
|
333
|
+
for field_name in ["security"]:
|
|
334
|
+
if field_name in config_fields:
|
|
335
|
+
jira_fields[field_name] = {"name": config_fields[field_name]}
|
|
336
|
+
|
|
337
|
+
# Add optional fields that require nested formatting with "name" key and stringified value
|
|
338
|
+
for field_name in ["priority"]:
|
|
339
|
+
if field_name in config_fields:
|
|
340
|
+
jira_fields[field_name] = {"name": str(config_fields[field_name])}
|
|
341
|
+
|
|
342
|
+
# Add optional fields with a list of values that require nested formatting with "name" key
|
|
343
|
+
for field_name in ["components", "versions", "fixVersions"]:
|
|
344
|
+
if field_name in config_fields:
|
|
345
|
+
jira_fields[field_name] = [
|
|
346
|
+
{"name": field_value} for field_value in config_fields[field_name]
|
|
347
|
+
]
|
|
348
|
+
|
|
349
|
+
# Add any custom fields defined in the issue, which may have arbitrary formatting
|
|
350
|
+
if "customFields" in config_fields:
|
|
351
|
+
jira_fields.update(config_fields["customFields"])
|
|
352
|
+
|
|
353
|
+
return jira_fields
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Logger for jirabatch."""
|
|
2
|
+
|
|
3
|
+
from conflog import Conflog
|
|
4
|
+
|
|
5
|
+
LOGGER = None
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def init():
|
|
9
|
+
"""Initialize logger.
|
|
10
|
+
|
|
11
|
+
Logger is cached to prevent duplicate handlers
|
|
12
|
+
from being added on repeated calls.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
global LOGGER # pylint: disable=global-statement
|
|
16
|
+
if LOGGER is not None:
|
|
17
|
+
return LOGGER
|
|
18
|
+
|
|
19
|
+
cfl = Conflog(
|
|
20
|
+
conf_dict={"level": "info", "format": "[jirabatch] %(levelname)s %(message)s"}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
LOGGER = cfl.get_logger(__name__)
|
|
24
|
+
return LOGGER
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [ "poetry-core" ]
|
|
3
|
+
build-backend = "poetry.core.masonry.api"
|
|
4
|
+
|
|
5
|
+
[installer]
|
|
6
|
+
no-binary = [ ":none:" ]
|
|
7
|
+
|
|
8
|
+
[tool.poetry]
|
|
9
|
+
name = "jirabatch"
|
|
10
|
+
version = "0.10.0"
|
|
11
|
+
description = "Create Jira tickets via YAML"
|
|
12
|
+
license = "Apache-2.0"
|
|
13
|
+
authors = [ "Cliffano Subagio <cliffano@gmail.com>" ]
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
homepage = "https://github.com/cliffano/jirabatch"
|
|
16
|
+
repository = "https://github.com/cliffano/jirabatch"
|
|
17
|
+
documentation = "https://github.com/cliffano/jirabatch"
|
|
18
|
+
keywords = [ "jirabatch", "jira", "issues" ]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"License :: OSI Approved :: Apache Software License",
|
|
22
|
+
"Operating System :: OS Independent"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[[tool.poetry.packages]]
|
|
26
|
+
include = "jirabatch"
|
|
27
|
+
|
|
28
|
+
[tool.poetry.scripts]
|
|
29
|
+
jirabatch = "jirabatch:cli"
|
|
30
|
+
|
|
31
|
+
[tool.poetry.dependencies]
|
|
32
|
+
python = "^3.10"
|
|
33
|
+
cfgrw = "~1.1.0"
|
|
34
|
+
click = "~8.3.3"
|
|
35
|
+
conflog = "~2.1.1"
|
|
36
|
+
jira = "~3.10.5"
|
|
37
|
+
PyYAML = "~6.0.3"
|
|
38
|
+
|
|
39
|
+
[tool.poetry.group.dev.dependencies]
|
|
40
|
+
black = "~26.5.0"
|
|
41
|
+
twine = "~6.2.0"
|
|
42
|
+
wheel = "~0.47.0"
|
|
43
|
+
|
|
44
|
+
[tool.poetry.group.test.dependencies]
|
|
45
|
+
coverage = "~7.14.0"
|
|
46
|
+
numpy = "1.26.4"
|
|
47
|
+
pylint = "~4.0.5"
|
|
48
|
+
pytest = "~9.0.3"
|
|
49
|
+
wily = "~1.25.0"
|
|
50
|
+
|
|
51
|
+
[tool.poetry.group.doc.dependencies]
|
|
52
|
+
ansi2html = "~1.9.2"
|
|
53
|
+
pylint-report = "~2.4.2"
|
|
54
|
+
pytest-html = "~4.2.0"
|
|
55
|
+
Sphinx = "8.1.3"
|