Skip to content

Commit

Permalink
[FIXED JENKINS-9906] adding replacements to JOB_NAME substitution to …
Browse files Browse the repository at this point in the history
…remove invalid characters
  • Loading branch information
Rob Petti committed Jun 14, 2011
1 parent 1183de0 commit 2835992
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -428,7 +428,7 @@ else if (pta.getTag() != null) {

private Hashtable<String, String> getDefaultSubstitutions(AbstractProject project) {
Hashtable<String, String> subst = new Hashtable<String, String>();
subst.put("JOB_NAME", project.getFullName());
subst.put("JOB_NAME", getSafeJobName(project));
ParametersDefinitionProperty pdp = (ParametersDefinitionProperty) project.getProperty(hudson.model.ParametersDefinitionProperty.class);
if(pdp != null) {
for (ParameterDefinition pd : pdp.getParameterDefinitions()) {
Expand Down Expand Up @@ -1689,7 +1689,7 @@ static List<String> parseProjectPath(String projectPath, String p4Client) {

static String substituteParameters(String string, AbstractBuild build) {
Hashtable<String,String> subst = new Hashtable<String,String>();
subst.put("JOB_NAME", build.getProject().getFullName());
subst.put("JOB_NAME", getSafeJobName(build));
String hudsonName = Hudson.getInstance().getDisplayName().toLowerCase();
subst.put("BUILD_TAG", hudsonName + "-" + build.getProject().getName() + "-" + String.valueOf(build.getNumber()));
subst.put("BUILD_ID", build.getId());
Expand All @@ -1699,6 +1699,14 @@ static String substituteParameters(String string, AbstractBuild build) {
return result;
}

static String getSafeJobName(AbstractBuild build){
return getSafeJobName(build.getProject());
}

static String getSafeJobName(AbstractProject project){
return project.getFullName().replace('/','-').replace('=','-').replace(',','-');
}

static String substituteParameters(String string, Map<String,String> subst) {
if(string == null) return null;
String newString = string;
Expand Down

0 comments on commit 2835992

Please sign in to comment.