Skip to content

rstad/Jira-Workflow-XML-Logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jira Workflow XML Logger

Example / Demo

I started up a Jira trial locally, made some config changes over the course of a few days, and pointed this script at it periodically. The results can be found here: https://github.com/rstad/jira-workflow-log-example

Requirements

  • Python 3.6+
  • credentials for a user that has sufficient privileges to retrieve workflows from Jira
  • a repo you can access for committing changes to

I've only tested this against Server/DC, no idea if it would have any use with Cloud.

Usage

For now I'm just running this as a cron job but I'm sure you could adapt it for other use.

Manual steps:

  1. git clone this repo and cd into the directory.
  2. cp .env.example .env
  3. edit .env to have the appropriate values
  4. python3 -m venv env
  5. source env/bin/activate
  6. pip install -r requirements.txt
  7. python workflowlog.py

❯ python workflowlog.py -h
usage: workflowlog.py [-h] [--firstrun] [--nocleanup]

Script to capture changes to workflows in Jira

optional arguments:
  -h, --help   show this help message and exit
  --firstrun   Gets ALL workflows and attempts to make initial commit to an empty repo
  --nocleanup  prevents deleting work dir after run

Background

The idea for this script came up when I was talking to somebody about how we could better track who made changes to a workflow, and what changes they had made.

The actions we resolved to take from that meeting were to essentially ask people to remember to save backup copies of workflows when publishing updates. This sounded to me like a good opportunity to automate.

Approach

It's possible to get a list of all the workflows that Jira has, in a giant JSON blob. It was not immediately obvious to me how to tell which ones are active or inactive, but for the purposes of simply logging changes to workflows, that doesn't matter too much.

What the big list has that we do care about is:

  1. a lastModifiedDate
  2. a lastModifiedUser
  3. a uniquely identifying name

With this, the next question is, how do I get the workflow as an XML file, for the purposes of storing and performing diff against later?

It turns out that this is pretty straightforward by performing the appropriate series of requests to get authenticated, and then simply trying to download it by name using:

$JIRA_URL/secure/admin/workflows/ViewWorkflowXml.jspa?workflowMode=live&workflowName=My+Workflow+Name

So far, we've now got a list of every workflow, the XML for that workflow, who last modified that workflow (which is also in the XML), and when the workflow was last updated.

To put it all together, we use this script which will:

  1. Retrieve a list of all workflows
  2. Check for those that were last updated recently (e.g. since the last time the script was run)
  3. For each workflow identified, download the XML
  4. Add to a git repo and commit the changes

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages