Is there a way to provide Jenkins parameter(in string form) instead of expected int value in fields?

3,140 views
Skip to first unread message

Bob-theUnityBuilder

unread,
Feb 18, 2014, 7:53:21 PM2/18/14
to job-dsl...@googlegroups.com
Hi,

I see that Jenkins allows evaluation of strings at run time in lieu of providing integers in some fields.

One such place is copy artifact. I've created a pipeline job and I'm passing a paramter XYZ assigned with Build Number of upstream job to a job downstream. I tried to use the copyArtifacts(...) as follows - 

steps{
 copyArtifacts
(downstreamUnityJob.name,"target/**"){
   buildNumber
("\$UNITY_BUILD_NUMBER")
 
}
}

I get an error  - 
groovy.lang.MissingMethodException: No signature of method: static javaposse.jobdsl.dsl.helpers.StepContext.buildNumber() is applicable for argument types: (java.lang.String) values: [$UNITY_BUILD_NUMBER]

which is perfectly valid according to this code -
 https://github.com/jenkinsci/job-dsl-plugin/blob/master/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/CopyArtifactContext.groovy

So my question is, is there a way to pass evaluation parameters such as above to functions that don't accept them? 

If anyone knows any other way to handle this please let me know.

Thanks.
-G

Justin Ryan

unread,
Feb 18, 2014, 8:31:42 PM2/18/14
to job-dsl-plugin
That's most like a bug in CopyArtifactContext's buildNumber method signature. File a JIRA or a Pull Request.


--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/df8fac62-ac88-4a5b-b548-0146c10f26ff%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Robert Langley

unread,
Feb 26, 2014, 8:34:21 AM2/26/14
to job-dsl...@googlegroups.com
Filed here: https://issues.jenkins-ci.org/browse/JENKINS-21961

Is it possible to use a work around to change the value of the build number after the XML has been created? Curious as I want to get up and running as quickly as possible.

Thanks,

Matt Sheehan

unread,
Feb 27, 2014, 9:56:40 AM2/27/14
to job-dsl...@googlegroups.com
You can change it in the configure block like:

job {
  name 'test'
  steps{
   copyArtifacts('xxx','target/**'){
     buildNumber(0)
   }
  }
  configure { project ->
    project /
      builders / 
      'hudson.plugins.copyartifact.CopyArtifact' / 
      selector / 
      buildNumber('$UNITY_BUILD_NUMBER')
  }
}


Robert Langley

unread,
Feb 28, 2014, 6:32:01 AM2/28/14
to job-dsl...@googlegroups.com
Awesome, many thanks. I've also submitted a PR to get the origin issue fixed without the need to use the workaround.
Reply all
Reply to author
Forward
0 new messages