From 203eca26c13c69f9077c81a8764242ff4f7a9a22 Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 17 Dec 2014 12:24:36 +0000 Subject: [PATCH 1/2] New env variable exported: SVN_REVISION_HIGHEST --- src/main/java/hudson/scm/SubversionSCM.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/hudson/scm/SubversionSCM.java b/src/main/java/hudson/scm/SubversionSCM.java index 4c7e8ec20..decd86b2c 100755 --- a/src/main/java/hudson/scm/SubversionSCM.java +++ b/src/main/java/hudson/scm/SubversionSCM.java @@ -677,6 +677,7 @@ public void buildEnvVars(AbstractBuild build, Map env) { try { Map revisions = parseSvnRevisionFile(build); Set knownURLs = revisions.keySet(); + Long revHighest = 0; if(svnLocations.length==1) { // for backwards compatibility if there's only a single modulelocation, we also set // SVN_REVISION and SVN_URL without '_n' @@ -685,6 +686,7 @@ public void buildEnvVars(AbstractBuild build, Map env) { if(rev!=null) { env.put("SVN_REVISION",rev.toString()); env.put("SVN_URL",url); + revHighest = rev; } else if (!knownURLs.isEmpty()) { LOGGER.log(WARNING, "no revision found corresponding to {0}; known: {1}", new Object[] {url, knownURLs}); } @@ -696,10 +698,16 @@ public void buildEnvVars(AbstractBuild build, Map env) { if(rev!=null) { env.put("SVN_REVISION_"+(i+1),rev.toString()); env.put("SVN_URL_"+(i+1),url); + if (rev > revHighest) { + revHighest = rev; + } } else if (!knownURLs.isEmpty()) { LOGGER.log(WARNING, "no revision found corresponding to {0}; known: {1}", new Object[] {url, knownURLs}); } } + if (revHighest != null) { + env.put("SVN_REVISION_HIGHEST", revHighest.toString()); + } } catch (IOException e) { LOGGER.log(WARNING, "error building environment variables", e); From cad76e19abf47f4c373f2b4bc86ff6c4d0eba8a4 Mon Sep 17 00:00:00 2001 From: Gaspar de Elias Date: Wed, 17 Dec 2014 14:26:06 +0000 Subject: [PATCH 2/2] Fixed Long value revHighest initialization. Removed null check that is not needed --- src/main/java/hudson/scm/SubversionSCM.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/hudson/scm/SubversionSCM.java b/src/main/java/hudson/scm/SubversionSCM.java index decd86b2c..0a6e237bd 100755 --- a/src/main/java/hudson/scm/SubversionSCM.java +++ b/src/main/java/hudson/scm/SubversionSCM.java @@ -677,7 +677,7 @@ public void buildEnvVars(AbstractBuild build, Map env) { try { Map revisions = parseSvnRevisionFile(build); Set knownURLs = revisions.keySet(); - Long revHighest = 0; + Long revHighest = new Long(0); if(svnLocations.length==1) { // for backwards compatibility if there's only a single modulelocation, we also set // SVN_REVISION and SVN_URL without '_n' @@ -705,9 +705,7 @@ public void buildEnvVars(AbstractBuild build, Map env) { LOGGER.log(WARNING, "no revision found corresponding to {0}; known: {1}", new Object[] {url, knownURLs}); } } - if (revHighest != null) { - env.put("SVN_REVISION_HIGHEST", revHighest.toString()); - } + env.put("SVN_REVISION_HIGHEST", revHighest.toString()); } catch (IOException e) { LOGGER.log(WARNING, "error building environment variables", e);