Hello,
i have a problem with copying the fixversion from task in project A to task in projekt B. The copying works well and I have also some entries in the history-tab, but i can't filter for these version in the projekt releases view.
I think, the problem is that each project has unique versions, even if i name them the same and my script copies the version from project A to my task in project B. The name is the same but the ID is different.
How can I change my script to make this work? I think, that i have to compare the versions i get from project A to the versionlist of project B but I don't know how.
This is an extract of my script:
// Check if fixVersion is updated
if (LastChangeDate != null){
LastChangeDateFormat = LastChangeDate.format("yyyy-MM-dd hh:mm:ss")
}
if (LastChangeDateFormat >= currentDate) {
log.debug("${issueKey} fixVersions changed ${LastChangeDate}")
def fixVersions = issue.getFixVersions()
log.debug("FixVersion lautet ${fixVersions}")
// Updating FixVersions in Customer Issue
if (issueLinkManager.getOutwardLinks(issue.getId()).findAll {it.issueLinkType.name == 'Customer Project'}) {
for (IssueLink link in issueLinkManager.getOutwardLinks(issue.getId()).findAll {it.issueLinkType.name == 'Customer Project'}) {
def destIssueCust = link.getDestinationObject()
//versionManager.updateIssueFixVersions(destIssueCust, fixVersions);
//ComponentAccessor.getIssueManager().updateIssue(CurrentUser, missue, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false);
destIssueCust.setFixVersions(fixVersions)
ComponentAccessor.getIssueManager().updateIssue(CurrentUser, destIssueCust, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false);
log.debug("${issueKey} fixVersions changed in customer issue ${destIssueCust}")
}
}
I found a solution. I added a loop were the fixversion is cut into the different versions, saves as a string and after that i searched for this string in the projekt versions of the linked issue.
The problem was that we have the same release in different projects and my script copies version from the project A to project B with the false ID.
This is my new code:
// Check if fixVersion is updated
if (LastChangeDate != null){
LastChangeDateFormat = LastChangeDate.format("yyyy-MM-dd hh:mm:ss")
}
if (LastChangeDateFormat >= currentDate) {
log.debug("${issueKey} fixVersions changed ${LastChangeDate}")
def fixVersions = issue.getFixVersions()
log.debug("FixVersion DEV-Ticket lautet ${fixVersions}")
// Updating FixVersions in Customer Issue
if (issueLinkManager.getOutwardLinks(issue.getId()).findAll {it.issueLinkType.name == 'Customer Project'}) {
for (IssueLink link in issueLinkManager.getOutwardLinks(issue.getId()).findAll {it.issueLinkType.name == 'Customer Project'}) {
def destIssueCust = link.getDestinationObject()
def projectCust = destIssueCust.getProjectObject().getId();
def versionsCust = []
log.debug("Projekt = ${projectCust}")
for (version in fixVersions) {
String strVersion = version
versionsProject = versionManager.getVersion(projectCust, strVersion)
versionsCust.add(versionsProject)
}
destIssueCust.setFixVersions(versionsCust)
log.debug("FixVersion CUST-Ticket lautet ${destIssueCust.getFixVersions()}")
ComponentAccessor.getIssueManager().updateIssue(CurrentUser, destIssueCust, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_UPDATED, false);
log.debug("${issueKey} fixVersions changed in customer issue ${destIssueCust}")
}
}
@Müller_ Julian Hi
Can you try moving your issue to "Done" ?
I was trying a similar code and the fix version is copied into my issue, but when I search in jql, there were no results.
I move the issue to Done, and then the jql worked .
Let me know if this works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I forgot to add this.
Here , I search for X version .
Then I search in the list of versions and add to another list of versions the one that I need.
List<Version> vers = ComponentAccessor.getVersionManager().getVersionsByName("test") as List
List<Version> issueVersions = new ArrayList<Version>()
//This will print the project Name of each version
log.warn vers.get(0).getProject()
log.warn vers.get(1).getProject()
//Since I know I want the version with id 1
issueVersions.add(vers.get(1))
issueToBeCopied.setFixVersions(issueVersions)
issueManager.updateIssue....
Let me know if you try it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found a solution. I added a loop were the fixversion is cut into the different versions, saves as a string and after that i searched for this string in the projekt versions of the linked issue.
The problem was that we have the same release in different projects and my script copies version from the project A to project B with the false ID.
This is my new code:
// Check if fixVersion is updated
if (LastChangeDate != null){
LastChangeDateFormat = LastChangeDate.format("yyyy-MM-dd hh:mm:ss")
}
if (LastChangeDateFormat >= currentDate) {
log.debug("${issueKey} fixVersions changed ${LastChangeDate}")
def fixVersions = issue.getFixVersions()
log.debug("FixVersion DEV-Ticket lautet ${fixVersions}")
// Updating FixVersions in Customer Issue
if (issueLinkManager.getOutwardLinks(issue.getId()).findAll {it.issueLinkType.name == 'Customer Project'}) {
for (IssueLink link in issueLinkManager.getOutwardLinks(issue.getId()).findAll {it.issueLinkType.name == 'Customer Project'}) {
def destIssueCust = link.getDestinationObject()
def projectCust = destIssueCust.getProjectObject().getId();
def versionsCust = []
log.debug("Projekt = ${projectCust}")
for (version in fixVersions) {
String strVersion = version
versionsProject = versionManager.getVersion(projectCust, strVersion)
versionsCust.add(versionsProject)
}
destIssueCust.setFixVersions(versionsCust)
log.debug("FixVersion CUST-Ticket lautet ${destIssueCust.getFixVersions()}")
ComponentAccessor.getIssueManager().updateIssue(CurrentUser, destIssueCust, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_UPDATED, false);
log.debug("${issueKey} fixVersions changed in customer issue ${destIssueCust}")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just a little news: I tested to add the fixVersions with Automation for Jira and had no problems.
I also noticed: When using Automation each fix version is deletable, which copying through script i can also delete the whole entry.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.