How to add a Jira Compass Component on components field from commit using jira automation?

David Ortiz Bollain February 14, 2025

Hello!

This is what I'm trying to achieve:

Given a sw issue
When commited
Then fetch the component from the commit and update components field as Compass Component

The problem that I have, is that when updating the Component field a non Compass Component is created and informed, even if the component exists. 

I've been able to:

  • Fetch the component name from a commit using text formatting smart values. 

From {{commit.url}} I've follow documentation Automation smart values - text fields | Cloud automation Cloud | Atlassian Support

I save the component name on this variable {{Component}}, that I use later.

  • Update the component field

Creating two variables:

{{ExistingComponents}} = {{#issue.components}}{ "name": "{{name}}"} {{^last}}, {{/}}{{/}}

{{AllComponents}} = {{ExistingComponents}} , { "name": "{{Component}}"}

Editing issue Components field:

{ "fields": { "components" : [ {{AllComponents}} ] } }

 

All Compass Components were overwrited and when I hover over the components I get this message:

 

component-name can be removed from this issue, but to add it again, switch to Jira components from the Components page.

2 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2025

Hi @David Ortiz Bollain 

For a question like this, context is important for the community to help.  Please post the following:

  • as you note Compass Components, I assume this is a Company-managed project: is that correct?
  • an image of your complete automation rule in a single image for continuity,
  • images of any relevant actions / conditions / branches,
  • an image of the audit log details showing the rule execution, and
  • explain what is not working as expected and why you believe that to be the case.

Until we see those...

Have you tried writing those created variables to the audit log when the rule runs to confirm they contain what you expected?

Kind regards,
Bill

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2025

Thanks for that information, @David Ortiz Bollain 

Please try to stay with one thread when responding.  That will help others reading this in the future know if there are multiple possible solutions to the question.  Thanks!

When creating variables, I recommend not using names which could be confused (by a person or automation) with existing smart values.  One way to do that is to always add a prefix to variable names, for example using varCommit versus Commit.

 

Back to your question...

After some research, I found this suggestion to add automation support for Compass Components: https://jira.atlassian.com/browse/AUTO-1219 which is marked as "fixed", but I found a problem...my testing shows when using JSON to add the Compass Component by name, it instead adds standard Components to both the issue and project.

Adding it using the Compass Component by ID with JSON does work as expected.

If you only have the name and the Compass Component has already been assigned to issues in the project, you could use the REST API and the Send Web Request action to find the ID, filtering by the componentSource=compass and query=yourName

 

David Ortiz Bollain February 18, 2025

Thank you for your quick response.

We will check the workaround and keep an eye on AUTO-1219.

Like Bill Sheboy likes this
0 votes
David Ortiz Bollain February 17, 2025

Thank you for your reply Bill.

We have several company-managed projects that share n Compass components. 

We are able to fetch a component from a commit and inform the component field, but Jira do not identify it as a Compass component

On commit creation

1. {{Commit}} variable is {{commit.url}}

commit_url.GIF

2. {{CommitShort}} variable is {{Commit.replace("repo instance", "")}}

commit_short.GIF

3. {{Component}} variable is {{CommitShort.split("/").first}}

component.GIF

After these steps we are able to get the component to add to the issue.

In the following steps we will add the component.

4. We identify the components that are currently in the issue by creating {{Existing.Components}} variable {{#issue.components}}{ "name": "{{name}}"} {{^last}}, {{/}}{{/}}

Existing_components.GIF

5. We add the new component identified in step 3. Creating a new variable {{AllComponents}} that concatenates the variables from step 3 and 4: {{ExistingComponents}} , { "name": "{{Component}}"}
AllComponents.GIF

 

6. All components, old and new, are added to the Component field.

{
"fields": {
"components" : [ {{AllComponents}} ]
}
}

Advanced.GIF

 

Components are informed, but Jira does not consider them to be Compass Components, when we hover over the component we get this information.

added components.GIF

These components are present in our Compass Component application, with the same name, but when informed via automation, are not identified as Compass Components, instead old version components are created and informed.

Compass switch is active for those projects.

Overview of the automation:

On commit fetch component.GIF

In this example, we can see how a component is identified from the commit, and shares name with a Compass component already present in the issue.
When editing the component field only one component is informed, a non Compass component, and the Compass component is not present anymore.
Audit log.GIF

history.GIF

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events