/rally2alc

A project to find rally user stories and trigger webhook calls to ALC

Primary LanguagePython

rally2alc

A project to find rally user stories and trigger webhook calls to ALC (or any other server, as the URL is configurable).

Some companies have strict firewall considerations. This was written to allow webhook like functionality from Agile Central/Rally to an aribritary server. This is a basic implementation and only performs unauthenticated posts.

This was written to overcome a limitation with Agile Central's webhook functionality. AC Webhooks, currently in beta, do not allow mutual authentication over TLS or OAUTH. So it is not possible to use AC Webhooks for those sites that need it.

An option is uisng Request.bin or NGROK as a reverse proxy into environments, but some sites believe this to be unsafe.

If those options don't work for you, this might.

Requirements: Python 3.6+

Tested on Ubuntu Server 18.04 and Windows 10

NOTES: Webhooks are powerful because you can set up the firing mechanism. They will fire when the condition is met, especially event driven systems, like Agile Central. This does not use an event driven mechanism. It uses the query system and a timestamp to check for changes. A query, like below, would fire if you updated an item in the Completed state, even if the status doesn't change.

((ScheduleState = Completed) AND (LastUpdateDate > lastruntime))

To prevent this, each Formatted ID is stored in a file. This file is referenced so it will not fire again. However, this presents another issue. What if the story is rejected and it goes to In-progress again? Yes, it shouldn't, but things happen. You may want the webhook to fire again. If you want the webhook to fire again, you need to set the "Cleanup Query" and "Run Cleanup" settings in the config file. The cleanup query should contain the filter specifying when the User Story should be allowed to fire again. In the example, it will allow it to fire any time it has changed status from Completed.

Note: There are times the webhook will not fire again. If the run interval is set for 5 minutes, it will run the cleanup query every 5 minutes. If the user changes the ScheduleState from Completed to In-Progess and back to Completed before the next loop has run, it will not run the webhook. Agile Central does not have a "previous value" setting within the WSAPI API, therefore this was the workaround chosen

The query options have a single special tag. It is used to specific the "LastUpdateDate" value. Using this query:

((ScheduleState = Completed) AND (LastUpdateDate > {})) The system will evaluate this to something like: ((ScheduleState = Completed) AND (LastUpdateDate > 2018-08-16T20:08:06.7372Z))

You should always use the LastUpdateDate as part of your query, otherwise it will scan every User Story in the system, every time. That is not very efficient.

Config File Here's a notated example. See the included config.ini and modify it as needed: [Rally] #Section dealing with Rally Options API Key = #This uses only the API key to log in. No username/password. URL = rally1.rallydev.com #URL for Agile Central. If you are on-premise, change this. Workspace = thomas.mcquitty@ca.com-2017-05-May #Workspace to process Project = Shopping Team #Projec to process Query = ((ScheduleState = Completed) AND (LastUpdateDate > {})) #This is the query, if it matches, will fire the webhook Cleanup Query = ((ScheduleState != Completed) AND (LastUpdateDate > {})) #to reset the story so it will fire again, it has to meet this critera

[ALC] Endpoint = http://localhost/rest/eventhook?apikey=ads&processorid=6011123 #This is the endpoint for sending the webhook.

[Rally2ALC]
Run Interval = 5 #How often should this run, in minutes Run Cleanup = yes # Should we run the cleanup. Options are yes/no. Story Log Filename = Stories.log #Filename containing formatted ids of stories to be proceessed

Story Log Filename may get large. This will contain a line for each story processed by Rally2ALC.
When the Cleanup option is set, it will find all the stories that match the cleanup critiera. It will remove the story ids from this file. It treats it as if it has never fired if the formatted id is not found in this file. That's how the cleanup operation works. It will fire after all the webhooks are fired.

NOTE: Prior to running, create a LOGS directory. The logging will be stored in there. If the directory does not exist, an error will occur.