Skip to content

Commit

Permalink
[JENKINS-5608] take advantage of new methods in 1.421 to work better …
Browse files Browse the repository at this point in the history
…with promoted-builds plugin
  • Loading branch information
kohsuke committed Nov 4, 2011
1 parent b9af8be commit 31f2c7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.420</version>
<version>1.421</version>
</parent>
<artifactId>svn-tag</artifactId>
<name>Jenkins Subversion Tagging Plugin</name>
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/hudson/plugins/svn_tag/SvnTagPlugin.java
Expand Up @@ -72,30 +72,33 @@ public static boolean perform(AbstractBuild<?,?> abstractBuild,
return true;
}

// in the presence of Maven module build and promoted builds plugin (JENKINS-5608),
// we rely on the root project to find the SCM configuration and revision to tag.
AbstractProject<?, ?> rootProject =
abstractBuild.getProject().getRootProject();
AbstractBuild<?, ?> rootBuild = abstractBuild.getRootBuild();

if (!(rootProject.getScm() instanceof SubversionSCM)) {
logger.println(Messages.NotSubversion(rootProject.getScm().toString()));
return true;
}

SubversionSCM scm = SubversionSCM.class.cast(rootProject.getScm());
EnvVars envVars = abstractBuild.getEnvironment(buildListener);
EnvVars envVars = rootBuild.getEnvironment(buildListener);

// Let SubversionSCM fill revision number.
// It is guaranteed for getBuilds() return the latest build (i.e.
// current build) at first
// The passed in abstractBuild may be the sub maven module and not
// have revision.txt holding Svn revision information, so need to use
// the build associated with the root level project.
scm.buildEnvVars(rootProject.getBuilds().get(0), envVars);
scm.buildEnvVars(rootBuild, envVars);

// environment variable "SVN_REVISION" doesn't contain revision number when multiple modules are
// specified. Instead, parse revision.txt and obtain the corresponding revision numbers.
Map<String, Long> revisions;
try {
revisions = parseRevisionFile(abstractBuild);
revisions = parseRevisionFile(rootBuild);
} catch (IOException e) {
logger.println(
Messages.FailedParsingRevisionFile(e.getLocalizedMessage()));
Expand All @@ -115,9 +118,9 @@ public static boolean perform(AbstractBuild<?,?> abstractBuild,

SVNCommitClient commitClient = new SVNCommitClient(sam, null);

for (SubversionSCM.ModuleLocation ml : scm.getLocations(envVars, abstractBuild)) {
String mlUrl = null;
URI repoURI = null;
for (SubversionSCM.ModuleLocation ml : scm.getLocations(envVars, rootBuild)) {
String mlUrl;
URI repoURI;
try {
mlUrl = ml.getSVNURL().toString();
repoURI = new URI(mlUrl);
Expand Down

0 comments on commit 31f2c7d

Please sign in to comment.