[JIRA] (JENKINS-39417) JobDSL "configure" block can be called multiple times

2016-11-01 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-39417  
 
 
  JobDSL "configure" block can be called multiple times   
 

  
 
 
 
 

 
Issue Type: 
  Bug  
 
 
Assignee: 
 Daniel Spilker  
 
 
Components: 
 job-dsl-plugin  
 
 
Created: 
 2016/Nov/01 6:31 PM  
 
 
Priority: 
  Major  
 
 
Reporter: 
 Chris Price  
 

  
 
 
 
 

 
 When using a configure block within a with block, it seems that the configure block may be executed multiple times. For example, I have a job that looks basically like this: 

 

def job = workflowJob(job_prefix) {
parameters {
  ...
}
definition {
cpsScm {
scm {
git {
remote {
url(git_repo)
}
branch(git_branch)
}
}
scriptPath(relative_jenkinsfile)
}
}
logRotator {
numToKeep(50)
}
}

job.with {
out.println("IN JOB.WITH BLOCK")
triggers {
scm('H H(21-22) * * 1')
}
configure { Node project ->
out.println("EXECUTING JOB CONFIGURE")
}
}
 

 When I run the seed job, I see the IN JOB.WITH BLOCK message only once, but the EXECUTING JOB CONFIGURE message is printed three times.  
 

  
 
 
 
 

  

[JIRA] (JENKINS-37214) switch statement with regexes doesn't work in Pipeline DSL

2016-08-05 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-37214  
 
 
  switch statement with regexes doesn't work in Pipeline DSL   
 

  
 
 
 
 

 
Issue Type: 
  Bug  
 
 
Assignee: 
 Jesse Glick  
 
 
Components: 
 workflow-plugin  
 
 
Created: 
 2016/Aug/05 1:56 PM  
 
 
Priority: 
  Minor  
 
 
Reporter: 
 Chris Price  
 

  
 
 
 
 

 
 In a script that is loaded via load from a pipeline job, I have some code that looks like this:  

 
 switch (version) { case ~/^3\.[78]\..*/: return "blah" case ~/^3\..*/: return "bloop" default: return "Unrecognized version: '${version}'" }  

  This script fails to load in Jenkins, with the following error:  

 
 org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.ScriptBytecodeAdapter bitwiseNegate java.lang.Object at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectStaticMethod(StaticWhitelist.java:174) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onStaticCall(SandboxInterceptor.java:142) at org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:180) at org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:177) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:91) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15) at Script1.get_server_era(Script1.groovy:8) at Script1.single_pipeline(Script1.groovy:129) at ___cps.transform___(Native Method) at 

[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price commented on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 jglick, in IRC, pointed me at GroovyShellDecorator. I can imagine adding a GroovyShellDecorator to the plugin, and having it check for a file like {{$ {workspace} /.jenkins/additional_classpath_entries}} and if it finds it, read lines from the file and add them to the classpath for the GroovyShell. However, jglick warned that this won't work for jobs that are running on jenkins nodes other than the master because their workspaces will be remote :/  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price edited a comment on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 It seems like this could be achieved by adding an  `  {{ additionalClasspathEntries ` }}  or similar argument to the constructor of  `  {{ CpsScmFlowDefinition ` }}  [here ]( | https://github.com/jenkinsci/workflow-cps-plugin/blob/f3958997d201d39a952c6572eb623a8730b822d7/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java#L63 ) ] , and then adding that to the  `  {{ GroovyShell ` }}  somewhere around [here ]( | https://github.com/jenkinsci/workflow-cps-plugin/blob/f3958997d201d39a952c6572eb623a8730b822d7/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java#L120 ) ] .Does that seem like a reasonable idea?  Can these  `  {{ FlowDefinition ` }}  classes support multiple constructors so that this new argument could be optional and avoid breaking backward compatibility?  I would be happy to try to work up a PR for this if it seems reasonable.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price edited a comment on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 Also, FWIW, for my particular use case I'm creating the pipeline jobs via the JobDSL plugin (because we have multiple  `Jenkinsfile`s  {{Jenkinsfiles}}  in a single repo), so if there was a way to add classpath setter method to the Pipeline job type and then call that from the JobDSL plugin that would work for us (though I imagine that coming up with a more general solution would be useful for many other users).  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price commented on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 It seems like this could be achieved by adding an `additionalClasspathEntries` or similar argument to the constructor of `CpsScmFlowDefinition` [here](https://github.com/jenkinsci/workflow-cps-plugin/blob/f3958997d201d39a952c6572eb623a8730b822d7/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java#L63), and then adding that to the `GroovyShell` somewhere around [here](https://github.com/jenkinsci/workflow-cps-plugin/blob/f3958997d201d39a952c6572eb623a8730b822d7/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java#L120). Does that seem like a reasonable idea? Can these `FlowDefinition` classes support multiple constructors so that this new argument could be optional and avoid breaking backward compatibility? I would be happy to try to work up a PR for this if it seems reasonable.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price edited a comment on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 Also, FWIW, for my particular use case I'm creating the pipeline jobs via the JobDSL plugin (because we have multiple  {{  ` Jenkinsfile }} ` s in a single repo), so if there was a way to add classpath setter method to the Pipeline job type and then call that from the JobDSL plugin that would work for us (though I imagine that coming up with a more general solution would be useful for many other users).  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price edited a comment on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 I wrote a plugin that provides an {{addToClasspath}} step for pipeline jobs:https://github.com/cprice404/pipeline-classpath-step-pluginIt works well for cases where your {{Jenkinsfile}} doesn't need to import any classes, but rather just calls {{load}} on other groovy scripts, and those groovy scripts {{import}} classes.  However, if I try to put any {{import}} statements directly in my {{Jenkinsfile}}, they seem to get processed before any other lines in the file, so the {{addToClasspath}} step doesn't get a chance to execute and the {{import}} fails. In IRC it was mentioned that perhaps the pipeline jobs could automatically add {{.jenkins/src}} to their classpath, but it'd be much nicer if that was configurable somehow.  e.g. if there was some property that could be set on the job to achieve it.  If anyone can provide any hints on how that might be achievable I would be happy to try to work on the implementation further.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price commented on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 Also, FWIW, for my particular use case I'm creating the pipeline jobs via the JobDSL plugin (because we have multiple {{Jenkinsfile}}s in a single repo), so if there was a way to add classpath setter method to the Pipeline job type and then call that from the JobDSL plugin that would work for us (though I imagine that coming up with a more general solution would be useful for many other users).  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-04 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price commented on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 I wrote a plugin that provides an addToClasspath step for pipeline jobs: https://github.com/cprice404/pipeline-classpath-step-plugin It works well for cases where your Jenkinsfile doesn't need to import any classes, but rather just calls load on other groovy scripts, and those groovy scripts import classes. However, if I try to put any import statements directly in my Jenkinsfile, they seem to get processed before any other lines in the file, so the addToClasspath step doesn't get a chance to execute and the import fails.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-02 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price commented on  JENKINS-37125  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
 I poked around in the issue tracker and didn't see a ticket that appeared to capture this, but if I missed something please feel free to close it as a dupe.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-37125) ability to write and use groovy classes from pipeline repos / scripts

2016-08-02 Thread ch...@puppet.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Chris Price created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-37125  
 
 
  ability to write and use groovy classes from pipeline repos / scripts   
 

  
 
 
 
 

 
Issue Type: 
  New Feature  
 
 
Assignee: 
 Jesse Glick  
 
 
Components: 
 workflow-plugin  
 
 
Created: 
 2016/Aug/02 5:18 PM  
 
 
Priority: 
  Major  
 
 
Reporter: 
 Chris Price  
 

  
 
 
 
 

 
 The `load` DSL method for Pipelines provides a nice way to load scripts and reference objects from a Pipeline script. However, it seems like it can be really useful to define simple classes in the SCM repo for a Pipeline job. E.g. just classes that represent simple data structures that you'd like to refer to in various steps of your pipelines, or Enum definitions, etc. Currently there does not seem to be a way to add to the classpath for the pipeline script so that an import would be able to pull in these class definitions. It would be really nice if there was a DSL method for adding to the classpath, or a way to define a property for the job that would allow you to specify additional classpath entries. It'd be totally fine for the scripting sandbox security requirements to apply to the groovy code loaded from the additional classpath entries.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment