From fd66871941ef9d0f51e4d8160e082fac0bd22c83 Mon Sep 17 00:00:00 2001 From: rodrigolopes Date: Fri, 7 Feb 2014 14:56:10 +0100 Subject: [PATCH] [FIXED JENKINS-3785] Created a Publisher to create a label on TFS after the build. The label is created in the workspace version. --- .../java/hudson/plugins/tfs/commands/LabelCommand.java | 9 +++++++-- .../hudson/plugins/tfs/commands/LabelCommandTest.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/hudson/plugins/tfs/commands/LabelCommand.java b/src/main/java/hudson/plugins/tfs/commands/LabelCommand.java index 609bc2871..399d0a3ea 100644 --- a/src/main/java/hudson/plugins/tfs/commands/LabelCommand.java +++ b/src/main/java/hudson/plugins/tfs/commands/LabelCommand.java @@ -25,12 +25,17 @@ public MaskedArgumentListBuilder getArguments() { arguments.add(labelName); arguments.add(projectPath); arguments.add(String.format("-version:W%s", workspaceName)); - arguments.add("-comment"); - arguments.add("Automatically applied by Jenkins TFS plugin"); + arguments.add(String.format("-comment:%s", getLabelComment())); arguments.add("-noprompt"); arguments.add("-recursive"); addServerArgument(arguments); addLoginArgument(arguments); return arguments; } + + private String getLabelComment() { + // TODO 1. Solve issue with quotes and spaces + // TODO 2. Include build information in the comment. + return "Automatically_applied_by_Jenkins_TFS_plugin"; + } } diff --git a/src/test/java/hudson/plugins/tfs/commands/LabelCommandTest.java b/src/test/java/hudson/plugins/tfs/commands/LabelCommandTest.java index d465081f7..5db465b96 100644 --- a/src/test/java/hudson/plugins/tfs/commands/LabelCommandTest.java +++ b/src/test/java/hudson/plugins/tfs/commands/LabelCommandTest.java @@ -19,6 +19,6 @@ public void assertArguments() { MaskedArgumentListBuilder arguments = new LabelCommand(config, "int_build.10", "Jenkins-JOB-MASTER", ".").getArguments(); assertNotNull("Arguments were null", arguments); - assertEquals("label int_build.10 . -version:WJenkins-JOB-MASTER -comment \"Automatically applied by Jenkins TFS plugin\" -noprompt -recursive -server:https://tfs02.codeplex.com -login:snd\\user_cp,password", arguments.toStringWithQuote()); + assertEquals("label int_build.10 . -version:WJenkins-JOB-MASTER -comment:Automatically_applied_by_Jenkins_TFS_plugin -noprompt -recursive -server:https://tfs02.codeplex.com -login:snd\\user_cp,password", arguments.toStringWithQuote()); } }