Skip to content
Permalink
Browse files

JENKINS-10325: fixing issue

- made more strings localizable, 
- added german localization
- now requires Jenkins 1.420+

Signed-off-by: cklein <carsten.klein@axn-software.de>
  • Loading branch information
cklein
cklein committed Jul 16, 2011
1 parent 1f4ddbb commit 86b78266641a25b88bd1634f338facbfbed3b91b
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/localizer"/>
<classpathentry kind="src" path="target/generated-sources/localizer"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
@@ -1,6 +1,3 @@
#Wed Jul 13 21:15:01 CEST 2011
#Sat Jul 16 15:57:31 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
16 pom.xml
@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.324</version>
<version>1.420</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>svn-tag</artifactId>
@@ -24,11 +24,6 @@
</developer>
</developers>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>subversion</artifactId>
<version>[1.1,)</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
@@ -41,5 +36,12 @@
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>subversion</artifactId>
<version>[1.28,)</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -2,6 +2,7 @@

import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import hudson.EnvVars;
import hudson.Launcher;
import hudson.model.*;
import hudson.scm.SubversionSCM;
@@ -54,14 +55,16 @@ private SvnTagPlugin() {
* @param tagBaseURLStr tag base URL string
* @param tagComment tag comment
* @return true if the operation was successful
* @throws InterruptedException
* @throws IOException
*/
@SuppressWarnings({"FeatureEnvy", "UnusedDeclaration", "TypeMayBeWeakened",
"LocalVariableOfConcreteClass"})
public static boolean perform(AbstractBuild<?,?> abstractBuild,
Launcher launcher,
BuildListener buildListener,
String tagBaseURLStr, String tagComment,
String tagDeleteComment) {
String tagDeleteComment) throws IOException, InterruptedException {
PrintStream logger = buildListener.getLogger();

if (!Result.SUCCESS.equals(abstractBuild.getResult())) {
@@ -72,47 +75,37 @@ public static boolean perform(AbstractBuild<?,?> abstractBuild,
AbstractProject<?, ?> rootProject =
abstractBuild.getProject().getRootProject();

Map<String, String> env;

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

SubversionSCM scm = SubversionSCM.class.cast(rootProject.getScm());
try {
env = abstractBuild.getEnvironment(buildListener);
} catch (Exception e) {
logger.println(
"Failed to get environment. " + e.getLocalizedMessage());
return false;
}
EnvVars envVars = abstractBuild.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), env);

SubversionSCM.ModuleLocation[] moduleLocations = scm.getLocations();

scm.buildEnvVars(rootProject.getBuilds().get(0), 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);
} catch (IOException e) {
logger.println(
"Failed to parse revision.txt. " + e.getLocalizedMessage());
Messages.FailedParsingRevisionFile(e.getLocalizedMessage()));
return false;
}

ISVNAuthenticationProvider sap =
scm.getDescriptor().createAuthenticationProvider();
scm.getDescriptor().createAuthenticationProvider(rootProject);
if (sap == null) {
logger.println("Subversion authentication info is not set.");
logger.println(Messages.NoSVNAuthProvider());
return false;
}

@@ -122,41 +115,40 @@ public static boolean perform(AbstractBuild<?,?> abstractBuild,

SVNCommitClient commitClient = new SVNCommitClient(sam, null);


for (SubversionSCM.ModuleLocation ml : moduleLocations) {
logger.println("moduleLocation: Remote ->" + ml.remote);

List locationPathElements =
Arrays.asList(StringUtils.split(ml.remote, "/"));

String evaledTagBaseURLStr =
evalGroovyExpression(env, tagBaseURLStr,
locationPathElements);

URI repoURI;
try {
repoURI = new URI(StringUtils.replace(ml.remote, " ", "%20"));
} catch (URISyntaxException e) {
logger.println("Failed to parse SVN repo URL. " +
e.getLocalizedMessage());
return false;
}
for (SubversionSCM.ModuleLocation ml : scm.getLocations(envVars, abstractBuild)) {
String mlUrl = null;
URI repoURI = null;
try {
mlUrl = ml.getSVNURL().toString();
repoURI = new URI(mlUrl);
} catch (SVNException e) {
logger.println(
Messages.FailedParsingRepositoryURL(ml.remote, e.getLocalizedMessage()));
return false;
} catch (URISyntaxException e) {
logger.println(
Messages.FailedParsingRepositoryURL(ml.remote, e.getLocalizedMessage()));
return false;
}
logger.println(Messages.RemoteModuleLocation(mlUrl));

List<String> locationPathElements = Arrays.asList(StringUtils.split(mlUrl, "/"));
String evaledTagBaseURLStr = evalGroovyExpression(
envVars, tagBaseURLStr, locationPathElements);

SVNURL parsedTagBaseURL = null;
try {
parsedTagBaseURL = SVNURL.parseURIEncoded(
parsedTagBaseURL = SVNURL.parseURIDecoded(
repoURI.resolve(evaledTagBaseURLStr).toString());
logger.println(
"Tag Base URL: '" + parsedTagBaseURL.toString() + "'.");
logger.println(Messages.TagBaseURL(parsedTagBaseURL.toString()));
} catch (SVNException e) {
logger.println(
"Failed to parse tag base URL '" + evaledTagBaseURLStr +
"'. " + e.getLocalizedMessage());
logger.println(Messages.FailedParsingTagBaseURL(
evaledTagBaseURLStr, e.getLocalizedMessage()));
}

try {
String evalDeleteComment = evalGroovyExpression(
env, tagDeleteComment, locationPathElements);
envVars, tagDeleteComment, locationPathElements);
SVNCommitInfo deleteInfo =
commitClient.doDelete(new SVNURL[]{parsedTagBaseURL},
evalDeleteComment);
@@ -176,18 +168,25 @@ public static boolean perform(AbstractBuild<?,?> abstractBuild,

try {
String evalComment = evalGroovyExpression(
env, tagComment, locationPathElements);
SVNRevision rev = SVNRevision.create(Long.valueOf(revisions.get(ml.remote)));
envVars, tagComment, locationPathElements);

Long revision = revisions.get(mlUrl);
if (revision == null)
{
logger.println(Messages.RevisionNotAvailable(mlUrl));
}
SVNRevision rev = SVNRevision.create(revision);

SVNCommitInfo commitInfo =
copyClient.doCopy(new SVNCopySource[] {
new SVNCopySource(rev, rev, SVNURL.parseURIEncoded(ml.remote)) },
new SVNCopySource(rev, rev,
SVNURL.parseURIEncoded(mlUrl)) },
parsedTagBaseURL, false,
true, false, evalComment, new SVNProperties());
SVNErrorMessage errorMsg = commitInfo.getErrorMessage();

if (null != errorMsg) {
logger.println(errorMsg.getFullMessage());
logger.println(Messages.FailedToTag(errorMsg.getFullMessage()));
return false;
} else {
logger.println(Messages.Tagged(commitInfo.getNewRevision()));
@@ -254,10 +253,12 @@ static String evalGroovyExpression(Map<String, String> env, String evalText,
continue; // invalid line?
}
try {
revisions.put(line.substring(0, index),
Long.parseLong(line.substring(index + 1)));
revisions.put(SVNURL.parseURIEncoded(line.substring(0, index)).toString(),
Long.parseLong(line.substring(index + 1)));
} catch (NumberFormatException e) {
// perhaps a corrupted line. ignore
} catch(SVNException e) {
// perhaps a corrupted line. ignore
}
}
} finally {
@@ -10,3 +10,11 @@ DeleteOldTag=Delete old tag {0}.
NoOldTag=There was no old tag at {0}.
Tagged=Tagged as Revision {0}
CopyFailed=Subversion copy failed. {0}
RevisionNotAvailable=Revision not available for {0}.
FailedParsingRepositoryURL=Failed to parse SVN repository URL {0}. {1}
FailedParsingTagBaseURL=Failed to parse SVN Tag Base URL {0}. {1}
TagBaseURL=Tag Base URL: {0}.
RemoteModuleLocation=Remote Module Location: {0}.
NoSVNAuthProvider=No subversion authentication provider available.
FailedParsingRevisionFile=Failed to parse revision.txt. {0}
FailedToTag=Creating the tag failed with the following error: {0}
@@ -0,0 +1,20 @@
DisplayName=Erstellt Subversion Tags für erfolgreiche Builds.
DefaultTagBaseURL='http://subversion_host/project/tags/last-successful/${env[''JOB_NAME'']}'
DefaultTagComment='Tag erzeugt durch SvnTag Plugin. Build:${env[''BUILD_TAG'']}.'
DefaultTagDeleteComment=Tag gelöscht durch SvnTag Plugin.
MissingURL=Bitte geben Sie eine gültige URL ein.
BadGroovy=Überprüfen Sie Ihr Skript. {0}
UnsuccessfulBuild=Nicht erfolgreiche Builds werden nicht getagged.
NotSubversion=SvnTag Plugin kann keine Tags für das SCM {0} erstellen.
DeleteOldTag=Lösche bestehendes Tag {0}.
NoOldTag=Es existiert kein vorheriges Tag {0}.
Tagged=Tagged in der Revision {0}
CopyFailed=Das Erstellen des Tags ist fehlgeschlagen. {0}
RevisionNotAvailable=Es existiert keine Revision für {0}.
FailedParsingRepositoryURL=Die SVN repository URL {0} ist ungültig. {1}
FailedParsingTagBaseURL=Die SVN Tag Base URL {0} ist ungültig. {1}
TagBaseURL=Tag Base URL: {0}.
RemoteModuleLocation=Entfernter Modulpfad: {0}.
NoSVNAuthProvider=Authentifizierung an Subversion nicht möglich.
FailedParsingRevisionFile=Die Datei revision.txt konnte nicht gelesen werden. {0}
FailedToTag=Die Erzeugung des Tags schlug mit folgender Fehlermeldung fehl: {0}

0 comments on commit 86b7826

Please sign in to comment.
You can’t perform that action at this time.