Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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. Configure . 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

(image: 001_trigger.png)

2. Get the authorization token

...

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.
If you have already got it, you can reuse it.

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(warning) Important:
If you don’t have already created a Projectrak API token, you have to do so as described in the first steps of the above link. If you have already got it

  • “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.
If you have already one, you can reuse it.

3. Get all projects

Generate a base64 authentication for the Jira user

Generate a string in base64 with the text "<JIRA_USER>:<JIRA_API_TOKEN>"

...

Open a Linux terminal and execute this command:

Code Block
echo -n YOUR_JIRA_USER_EMAIL:YOUR_JIRA_API_TOKEN | base64
  1. Store the result (something like this):

(image: 002_jira_authentication.png)

Configure action

* 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 https://YOUR<your_INSTANCEinstance>.atlassian.net/rest/api/3/project

  • Headers:

    • Content-Type: application/json

    • Authorization: Basic c2VydmljZXRlYW2AZGVpc2VyLmNvbTpBTGN1bkwzNzQ1YTRBUFY3cXcwZkU3MkQ=-EXAMPLE  (The Authentication in Base64)Basic <Jira base64 authentication string>

  • HTTP method: POSTGET

  • Web request body: Custom data

    Custom data (ℹ️ Replace DUMMYAUTO for your project key)

    Code Block{ "key": "DUMMYAUTO", "name": "Test dummy project autogenerated", "description": "Description for Test dummy project autogenerated", "leadAccountId": "{{issue.reporter.accountId}}", "url": "https://www.deiser.com", "assigneeType": "UNASSIGNED", "projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-simplified-project-management" }

    Empty

  • Check: Delay execution of subsequent rule actions until we've received a response for this web request

    (image: 003_jira_projects.png)

...

8. Rule step: iterate each project

Add component → New branch → Advanced branching

  • Smart value: {{webResponse.body}}

  • Variable name: project

(image: 004_iterate_projects.png)

...

9. Rule step: get each project “end date” from Projectrak

Add component → New action → Send a web request

Info

For this example, our End date field from Projectrak has the id: 10

(warning) Replace using your id

Replace the <endDate_field_id> with the one obtained in step 0

  • Web request URL: https://profields-cloud.deiser.com/values/projects/{{issue.project.id}}/fields/10<endDate_field_id>

  • Headers:

  • 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)

(image: 005_get_projectrak_enddate.png)

...

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}}

(image: 006_create_enddate_variable.png)

...

  • Condition: does not equal

  • Second value: leave empty

...

12. Rule step: compare dates between the current date and end-date of Projectrak.

...

  • First value: {{endDateValue}}

  • Condition: less than

  • Second value: {{projectEnddatenow.format("yyyy-MM-dd")}}

(image: 007_compare_dates.png)

...

13. Rule step: get all unresolved project issues

Add component → New action → Lookup issues

  • JQL: project={{project.id}} and resolution is empty

(image: 008_lookup_issues.png)

...

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

(image: 009_compare_issues.png)

...

15. Rule step: update project status field to “Off track”

Add component → New action → Send a web request

Info

For this example, our status field from Projectrak has the id: 150166

(warning) Replace using your idReplace the <status_field_id> with the one obtained in step 0.

  • Web request URL: https https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/150166<status_field_id>

  • Headers:

  • HTTP method: POST

  • Web request body: Custom data

  • Custom data:

    72176

    {{projectrakOfftrackStatusId}} is the item ID of status field from Projectrak

Code Block
{
 "value": 72176{{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!