Skip to content
Permalink
Browse files
Merge pull request #8 from jbaiza/JENKINS-29573
  • Loading branch information
laszlomiklosik committed Aug 15, 2015
2 parents dffaec0 + 5c295c4 commit bc22b5ef0c26bf467ce77cc1869c6190295ab32e
Showing with 10 additions and 14 deletions.
  1. +10 −14 src/main/java/info/bluefloyd/jenkins/IssueUpdatesBuilder.java
@@ -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;
}
@@ -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 ) {
@@ -333,7 +328,8 @@ private void updateFixedVersions(SOAPClient client, SOAPSession session, RemoteI
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 );

0 comments on commit bc22b5e

Please sign in to comment.