How to sync Components between Jira projects

Salim Hammar February 2, 2022

Hello everyone

I would like the syncronize the composent who are in project n°1 and for example the project n°2 he can use the components who are in the project n°1. 

 

I'm find this script : ( https://mraddon.blog/2021/04/25/how-to-sync-components-between-jira-projects/ )

script_sync_components1.png

it's the second party

script_sync_components2.png

in this script i can enter the project key but he don't working 

You can help me ???

 

 

3 answers

Suggest an answer

Log in or Sign up to answer
1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2022

Ok, so this is not going to do what you think it is.  Rather than try to fix your scripts, I would like to check if you actually want to do this!

Components are project items, they do not go across projects.  The scripts you've got are broadly trying to duplicate, not share.

Components in different projects are different and independant things, no matter what their names are - Component "Cat" in project ABC is not the same component as "Dog" in project ABC or "Cat" in project DEF.

Are you sure you want duplicate component names?

Salim Hammar February 3, 2022

No i would like than a project n°1 use the project n°2 and when i add the components in the project n°2 the components he should syncronise for show ad use in the project n°1

 

Thanks in advance

Salim Hammar February 7, 2022

Hi

You have a idea ??

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2022

Um, as I said, you can't do that.

Issues in project n*1 can only show and use the components in project n*1, they can't use the components from project n*2.

Salim Hammar February 9, 2022

Hi @Nic Brough -Adaptavist- 

 

i have this errro when i create a new component :

 

2022-02-09 16:25:44,064 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2022-02-09 16:25:44,064 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.bc.project.component.ProjectComponentCreatedEvent, file: null
java.lang.NullPointerException: Cannot invoke method getId() on null object
at Script29.run(Script29.groovy:24)

 

You can help me please ?

0 votes
M Amine
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 8, 2022

Your script contains a small error. In fact "dest_prj" must contain project KEYs and not project names. 

 

Project keys cannot have spaces in them. 

0 votes
M Amine
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 8, 2022

Hi Salim,
@Nic Brough -Adaptavist- is right. You cannot share components between projects. 

The script you gave "duplicates" components between the two projects. Perhaps if you explain what is the end-user requirement we can help you? 

Salim Hammar February 9, 2022

Hi 

I have a error when i create the component 

Error : 

2022-02-09 16:25:44,064 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2022-02-09 16:25:44,064 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.bc.project.component.ProjectComponentCreatedEvent, file: null
java.lang.NullPointerException: Cannot invoke method getId() on null object
at Script29.run(Script29.groovy:24)

 

You can help me please ?

Salim Hammar February 10, 2022

Hi @M Amine 

I have this script he dupplicate the components between project and i would like when i change the name for the component , the name in the other project but actually when i change the name he create a new component with name changed

script_sync.png

 

You can help me ?

Thanks in advance

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 10, 2022

This is not going to work like that.  It can't because you don't know what you need to look for.

Imagine you've got a list of components, and the same list in the second project:

  • Dog
  • Bunny
  • Cat

If someone changes "Bunny" to "Guinea Pig" in TH, then 

How are you catching the event that they do that?

If you read the components in TH now, there is no Bunny, so you don't know what the change is from.  It actually looks like a delete.

Your code is going to have to get the whole list of components from both projects, compare them and try to guess what has changed.  If the list in source is longer, you know to add the missing ones, if the list is shorter, you'll need to delete a component from the destination, and if the list is the same length, you'll need to compare every item until you find the changed one.

TAGS
AUG Leaders

Atlassian Community Events