Manage Jira assets in your code or CLI.
- Python 3.8+
pip install jira-amt
You need to add these environment variables to use the CLI:
Variable | Description |
---|---|
JIRA_SERVER | Jira server address like https://jira.domain.com |
JIRA_PAT | Your personal access token |
After setting these variables, you can configure the CLI:
jira-amt init
This command will get everything from your Jira server and save them to ~/.jira
directory for later use. With this data, you don't need to know/use ID of each asset/attribute.
There is some commands to manage assets. Check them using the --help
flag.
The asset creation in CLI is not make sense, because you need to enter all attributes in command line. But you can use it in your code.
You can update asset's attribute using it's name. The script will get the asset id from the name automatically.
jira-amt attr <schema> <object> <asset name> <attr name> <attr value>
jira-amt attr "ITSM" "Servers" "Server-1" "IP" "1.2.3.4"
You can add comment to an asset using it's name. The script will get the asset id from the name automatically.
jira-amt comment <schema> <object> <asset name> <comment>
jira-amt comment "ITSM" "Servers" "Server-1" "This is a comment"
You can use this package in your code to manage Jira assets.
from jira_amt.jira import JiraAssetHandler
jira = JiraAssetHandler(
server="https://jira.domain.com",
pat="ABCD1234"
)
asset = jira.get_asset("schema", "object", "asset's name")
print(asset.text)
input = {
"Name": "Server-1",
"Status": "Running",
"Environment": "Production",
"OS": "Debian",
"IP": "1.2.3.4"
}
asset = jira.create_asset("schema", "object", input)
asset = jira.get_asset("schema", "object", "asset's name")
print(asset.text)
result = jira.add_comment("schema", "object", "asset's name", "comment")
print(result.status_code)
Don't be shy and reach out to us if you want to contribute 😉
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature