Skip to content

Commit

Permalink
Merge pull request #8 from jbaiza/JENKINS-29573
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlomiklosik committed Aug 15, 2015
2 parents dffaec0 + 5c295c4 commit bc22b5e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/main/java/info/bluefloyd/jenkins/IssueUpdatesBuilder.java
Expand Up @@ -218,23 +218,15 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
logger.println("The selected issues (" + issues.size() + " in total) are:");
}

// reset the cache
projectVersionNameIdCache = new ConcurrentHashMap<String, Map<String,String>>();

// add the ids of the fixed versions if there are any
// This will also create new versions, if the Option is given.
Collection<String> fixVersionIds = new HashSet<String>();
if ( ! fixedVersionNames.isEmpty() ) {
fixVersionIds.addAll( mapFixedVersionNamesToIds(client, session, issues.get(0).getProject(), fixedVersionNames, logger) );
}

// reset the cache
projectVersionNameIdCache = new ConcurrentHashMap<String, Map<String,String>>();

for (RemoteIssue issue : issues) {
listener.getLogger().println(issue.getKey() + " \t" + issue.getSummary());
updateIssueStatus(client, session, issue, logger);
addIssueComment(client, session, issue, logger);
updateIssueField(client, session, issue, logger);
updateFixedVersions(client, session, issue, fixVersionIds, logger);
updateFixedVersions(client, session, issue, logger);
}
return true;
}
Expand Down Expand Up @@ -267,13 +259,16 @@ String substituteEnvVar( String origin, String varName, String replacement ) {
return origin;
}

private void updateFixedVersions(SOAPClient client, SOAPSession session, RemoteIssue issue, Collection<String> fixVersionIds, PrintStream logger) {
private void updateFixedVersions(SOAPClient client, SOAPSession session, RemoteIssue issue, PrintStream logger) {
// NOT resettingFixedVersions and EMPTY fixedVersionNames: do not need to update the issue,
// otherwise:
if ( resettingFixedVersions || ! fixedVersionNames.isEmpty() ) {

//Copy The Given Remote ID's to be applied to a local Variable. In case Old Versions should be kept we need to add them here
Collection<String> finalVersionIds = fixVersionIds;
Collection<String> finalVersionIds = new HashSet<String>();
if ( ! fixedVersionNames.isEmpty() ) {
finalVersionIds.addAll( mapFixedVersionNamesToIds( client, session, issue.getProject(), fixedVersionNames, logger ) );
}

// if not reset origin fixed versions, then also merge their IDs to the set.
if ( ! resettingFixedVersions ) {
Expand Down Expand Up @@ -333,7 +328,8 @@ private Collection<String> mapFixedVersionNamesToIds( SOAPClient client, SOAPSes
logger.println( "Creating Non-existent version " + name + " in project " + projectKey );
RemoteVersion newVersion = client.addVersion(session, projectKey, name);
if(newVersion.getId() != null) {
ids.add(newVersion.getId());
ids.add(newVersion.getId());
map.put(name, newVersion.getId());
}
else {
logger.println( "There was a problem creating Version " + name + " in project " + projectKey );
Expand Down

0 comments on commit bc22b5e

Please sign in to comment.