job names with slashes

2,303 views
Skip to first unread message

t...@airtime.com

unread,
Aug 23, 2016, 5:04:24 PM8/23/16
to job-dsl-plugin
Hi,

I'm using the GitHub Organization Folder plugin, which creates folders of jobs in a "org/repo/branch-name" format. Some of the git branches have slashes ("/") in them (e.g., "release/1.0"). On Jenkins the slash in the branch name is replaced with "%2F" (url encoding), so the full job names becomes "org/repo/release%2F1.0". When I tried to use that name as the job name in the the job-dsl-plugin, I get the following exception due to the percent character in the name:

hudson.model.Failure: ‘%’ is an unsafe character
      at jenkins.model.Jenkins.checkGoodName(Jenkins.java:3718)
      at javaposse.jobdsl.plugin.JenkinsJobManagement.createOrUpdateConfig(JenkinsJobManagement.java:145)

Any suggestions?

Thanks,
Tom

Robert Kielty

unread,
Aug 24, 2016, 8:41:29 AM8/24/16
to job-dsl-plugin
Couple of notes 

1. The error is being reported from Jenkins Core so it may be useful to run this by jenkins developers

The code can be found here in jenkins/core/src/main/java/jenkins/model/Jenkins.java

for( int i=0; i<name.length(); i++ ) {
   char ch = name.charAt(i);
   if(Character.isISOControl(ch)) {
       throw new Failure(Messages.Hudson_ControlCodeNotAllowed(toPrintableName(name)));
   }
   if("?*/\\%!@#$^&|<>[]:;".indexOf(ch)!=-1)
       throw new Failure(Messages.Hudson_UnsafeChar(ch));
   }
}


Given the age of the code I doubt that it can be changed.

2. The obvious work-around would be to not have the ("/") in the branch name

Hope this helps,

Rob

t...@airtime.com

unread,
Aug 24, 2016, 12:56:16 PM8/24/16
to job-dsl-plugin
Thanks. I should probably clarify that when I don't use the job-dsl-plugin, the branches with slashes work just fine (the jobs are auto-created without issue by the GitHub Organization Folder plugin). The job names show up in Jenkins with the slash, but the underlying job on disk has the URL encoded form. From that I assumed that maybe I should be passing the name with slashes to the job-dsl plugin, but it looks like it would treat it as a filename: https://github.com/jenkinsci/job-dsl-plugin/blob/master/job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/JenkinsJobManagement.java#L144

e.g., given "org/repo/branch-name", where "branch-name" is "release/1.0", the plugin would think the jobName is "1.0".

That said, after looking at this plugin a bit more, it appears that it's meant to be used to fully manage the jobs and that mixing it with the GitHub Organization Folder plugin (https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Organization+Folder+Plugin) doesn't make sense since that plugin is creating the jobs, not job-dsl. (I was trying to use the job-dsl-plugin to modify jobs created by the github org folder plugin since some of the plugins I use have job-dsl support, but not pipeline support and I can run job-dsl from a pipeline)
Reply all
Reply to author
Forward
0 new messages