This example describes the automatic change of the project status to “Off track”, if the project end date is over and the project has unresolved issues.
0. Get the Projectrak Status field id
First of all, it's necessary to obtain the Projectrak “Status” and “End date” field ids from the Projectrak Field manager.
In the following example, the ids are
...
42288 for the status field and 42286
...
for the end date field.
...
1. Create an Automation rule
Go to: Settings \ System \ Global Automation, and create a new rule.
You can also go there with a direct link, just replacing <your_instance> with yours:
https://<your_instance>.atlassian.net/jira/settings/automation
2 . Rule step: configure a trigger
Create a new trigger → Scheduled
Select the basic section
Choose your specific time: in this case every day at 06:00 AM
...
3. Rule steps: get the Projectrak authorization token and store it in a variable
Note |
---|
If you don’t have a Projectrak API token yet, follow the first steps (1 to 5) of the link below. |
Add to the rule the last 2 steps described in this link: https://deiser-apps.atlassian.net/wiki/spaces/PROJECTRAKCLOUD/pages/1641490/How+to+create+a+Projectrak+authorization+in+Automation+for+Jira?src=search
“6. Get the Projectrak JWT”
“7. Store the JWT in a variable“
4. Rule step: get the “Off track” value id, from the Projectrak Status field
Add component → New action → Send web request
Info |
---|
Replace the <status_field_id> with the one obtained in step 0 |
Web request URL: https://profields-cloud.deiser.com/items/fields/<status_field_id>?query=Off track
Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
HTTP method: GET
Web request body: Empty
Check: Delay execution of subsequent rule actions until we've received a response for this web request
...
5. Rule step: store the Status id in a variable
Add component → New Action → Create variable
Variable name: projectrakOfftrackStatusId
Smart value: {{#webResponse.body.values}}{{id}}{{/}}
...
6. Rule step: generate a base64 authentication string for Jira
Note |
---|
If you don’t have a Jira API token yet, please go to this page and generate it. |
Open a Linux terminal and execute this command:
Code Block |
---|
echo -n JIRA_USER_EMAIL:JIRA_API_TOKEN | base64 |
* For Windows powershell, please refer this link.
Copy the result string, please.
7. Rule step: get all Jira projects
Add component → New action → Send web request
Web request URL: https://<your_instance>.atlassian.net/rest/api/3/project
Headers:
Content-Type: application/json
Authorization: Basic <Jira base64 authentication string>
HTTP method: GET
Web request body: Empty
Check: Delay execution of subsequent rule actions until we've received a response for this web request
...
8. Rule step: iterate each project
Add component → New branch → Advanced branching
Smart value: {{webResponse.body}}
Variable name: project
...
9. Rule step: get each project “end date” from Projectrak
Add component → New action → Send a web request
Info |
---|
Replace the <endDate_field_id> with the one obtained in step 0 |
Web request URL: https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/<endDate_field_id>
Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
HTTP method: GET
Web request body: Empty
Check: Delay execution of subsequent rule actions until we've received a response for this web request
Check: Continue running the rule even if the request response is not successful (i.e. non-200 response)
...
10. Rule step: store the Projectrak field value in a variable
Add component → New action → Create variable
Variable name: endDateValue
Smart value: {{webResponse.body.value.value}}
...
11. Rule step: check not empty project end-date
Add component → New condition → Advanced compare condition
First value: {{endDateValue}}
Condition: does not equal
Second value: leave empty
...
12. Rule step: compare dates between the current date and end-date of Projectrak.
Add component → New condition → Advanced compare condition
First value: {{endDateValue}}
Condition: less than
Second value: {{now.format("yyyy-MM-dd")}}
...
13. Rule step: get all unresolved project issues
Add component → New action → Lookup issues
JQL: project={{project.id}} and resolution is empty
...
14. Rule step: compare the number of unresolved issues
Add component → New condition → Advanced compare condition
First value: {{lookupIssues.size}}
Condition: does not equal
Second value: 0
...
15. Rule step: update project status field to “Off track”
Add component → New action → Send a web request
Info |
---|
Replace the <status_field_id> with the one obtained in step 0. |
Web request URL: https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/<status_field_id>
Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
HTTP method: POST
Web request body: Custom data
Custom data: {{projectrakOfftrackStatusId}} is the item ID of status field from Projectrak
Code Block |
---|
{
"value": {{projectrakOfftrackStatusId}}
} |
Check: Delay execution of subsequent rule actions until we've received a response for this web request
Check: Continue running the rule even if the request response is not successful (i.e. non-200 response)
...
And that’s all folks!