Inspiration
As a DevOps Engineer, have you ever wondered how some of the tasks can be automated when REST APIs are not available to rescue? Well here is a story that just shows how you can do it.
What it does
We are going to use Python, Selenium along wth PhantomJS to just automate anything that you like.
- Automate On-premise or Atlassian.net hosted JIRA / Confluence instances.
- Use headless browser such as PhantomJS to achieve automation at regular intervals
- Automate administration / user tasks across all Atlassian applications (current focus limited to JIRA and Confluence though)
- Automate multiple actions from single command (just add --action = x, --action = y)
JIRA Tasks Automation
(--app-name = JIRA)
- Disable notification schemes for all projects --action = disable_project_notification_schemes
- Mail Queue health check --action = check_jira_mail_queue_status
- LDAP sync status --action = check_ldap_sync_status
- Download attachments for all issues as per JQL --action = get_jira_attachments
- Add / update list of options associated to Selectfield (not yet available)
Confluence Automation
(default --app-name = Confluence)
- Update Global color scheme --action = update_global_color_scheme
- Update color scheme for all Wiki spaces --action = update_wiki_spaces_color_scheme
- Update general configuration --action = update_general_configuration
This is just a teaser trailer to demonstrate of tasks that you can automate. In summary, basically you automate any of the routine administration or user tasks using ACL. In future, plan is to add more automation tasks for other Atlassian applications such as Bitbucket Server, Crucible, Bamboo.
Future is bright, just stay tight!
How I built it
Using combination of Python, Selenium, PhantomJS and Click.
Challenges I ran into
- Need to find out patterns in order to automate routine tasks.
- Getting into gory details of html, locating elements without ids
- If network is slow, it's sometimes difficult to time user events such as entering value in text fields, form submissions etc.
Accomplishments that I'm proud of
- Saves tons of time
- Gives you freedom from not doing tasks that you don't like
- Makes you lazy, which in turn encourages more automation
What I learned
- Life is beautiful when you don't have to do boring tasks!
What's next for Automate Atlassian from Command Line
- Focus for this submission is on Confluence and JIRA application.
- Future plan is to provide automation for other Atlassian applications such as Stash, Bamboo and other tools not yet covered.
How to use this Add On
- Detailed instructions are available on github
- Clone source from Automate Atlassian from Command Line git repository
- Install headless browser PhantomJS if you like to.
- Install Virtual Environment
- create virtual environment for python 2.7+ virtualenv -p /usr/bin/python2.7 venv
- Activate this newly installed virtual environment _source ./venv/bin/activate
- Install "Atlassian Command Line" as a python module -> pip install --editable .
- Use userid: admin and password: pongbot to play with test instance https://pongbot.atlassian.net
- Run Atlassian Command Line from command line as follows:
> acl --help
This will provide detail information on all parameters available and how to use ACL
- Examples
> acl
* In above case, ACL will use all default values as mentioned below:
--base-url=https://pongbot.atlassian.net, --app-type=atlassian.net, --app-name=Confluence, --browser-name=Firefox
-- Automate Confluence Wiki hosted on *Atlassian.net*
> acl --base-url https://pongbot.atlassian.net --action 'update_general_configuration'
> acl --app-type 'atlassian.net' --base-url https://pongbot.atlassian.net --userid admin --action 'update_global_color_scheme' --action 'update_general_configuration'
-- Automate on-premise Confluence Wiki ( Update Global Color Scheme )
> acl --app-type other --base-url https://example.com/wiki --userid admin --password admin --action 'update_global_color_scheme'
-- Automate Global color scheme updates, all wiki spaces color scheme updates, update general configuration (just "title" change right now) of Confluence application
> acl --app-type 'atlassian.net' --base-url https://pongbot.atlassian.net --action 'update_global_color_scheme' --action 'update_wiki_spaces_color_scheme' --action 'update_general_configuration' --userid <userid> --password <password>
- Automate act of disabling notification schemes for all JIRA projects
> acl --app-type 'atlassian.net' --base-url https://pongbot.atlassian.net --userid admin --action 'disable_project_notification_schemes' --app-name JIRA --password <password> --browser-name PhantomJS
- Automate JIRA Outgoing Mail Queue check
> acl --app-type 'other' --base-url https://jira.example.com --userid admin --app-name JIRA --password 'password' --browser-name PhantomJS --action 'check_jira_mail_queue_status' --mail_threshold_limit 100
- Automate the act of downloading all attachments as per JQL
-- Default JQL = created = now()
> acl --app-name JIRA --action get_jira_attachments --userid admin --password pongbot --browser-name PhantomJS --jql "key=TEST-1"
- Automate JIRA LDAP Sync Status check and Outgoing mail queue check
- ACL will warn user if LDAP sync status time is greater than default LDAP Threshold limit (4 hours) and Mails in Mail queue are greater than default Mail threshold limit (100 emails)
> acl --app-type 'other' --base-url https://jira.example.com --userid <admin> --app-name JIRA --password 'password' --browser-name PhantomJS --action 'check_jira_mail_queue_status' --action 'check_ldap_sync_status'
- Automate JIRA LDAP Sync Status check and Outgoing mail queue check against input threshold values
-- ACL will warn user if LDAP sync status time is greater than given LDAP Threshold limit (1 hour) and Mails in Mail queue are greater than given Mail threshold limit (50 emails)
> acl --app-type 'other' --base-url https://jira.example.com --userid <admin> --app-name JIRA --password <password> --browser-name PhantomJS --action 'check_jira_mail_queue_status' --mail-threshold-limit 50 --action 'check_ldap_sync_status' --ldap-sync-threshold-limit 1
Notes:
- Uses config/wiki_global_custom_colour_scheme.default as color scheme file input. Update colors as required.
- If userid and password are not entered from command line, application will prompt for these values before start of each run.
Log in or sign up for Devpost to join the conversation.