[JIRA] [workflow-plugin] (JENKINS-32780) Parameterize Multibranch Pipeline via Jenkinsfile

296 views
Skip to first unread message

michael.scharp@fmr.com (JIRA)

unread,
Feb 4, 2016, 12:18:02 PM2/4/16
to jenkinsc...@googlegroups.com
Michael Scharp created an issue
 
Jenkins / New Feature JENKINS-32780
Parameterize Multibranch Pipeline via Jenkinsfile
Issue Type: New Feature New Feature
Assignee: Jesse Glick
Components: workflow-plugin
Created: 04/Feb/16 5:17 PM
Priority: Major Major
Reporter: Michael Scharp

Hi,

I have a workflow that need a user input at some stage.
However, due to the frequent commits, which trigger the builds, I get to the case when I have several builds of the same workflow stay idle in the list awaiting the user input.

I would expectr my workflow to discard older builds if the newer build has reached the same stage.

But I cannot succeed that goal.

If I use the workflow like:

stage title: 'DevBuild', concurrency: 1
// do build
stage title: 'Integration', concurrency: 1
input message: 'Proceed?'
// do integration

then the very first build enters 'Integration' stage and pauses for user input. The other newer builds may superseed each other, but there is always the last build that gets to 'Integration' stage and waits until the very first build completes (because it cannot enter stage Integration).

I would like the newer build to discard the older build which waits for user input in this case, so that newer build can be decided by the user.

Is it possible to implement such a scenario?

Thank you

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

michael.scharp@fmr.com (JIRA)

unread,
Feb 4, 2016, 12:27:01 PM2/4/16
to jenkinsc...@googlegroups.com
Michael Scharp updated an issue
Change By: Michael Scharp
Hi, 

I  have a workflow that need a user input at some stage. 
However
 apologize if this feature is already present ,  due to the frequent commits, which trigger the builds,  but  I  get 've googled and read through the documentation and haven't been able  to  find out how to do this.

One of
 the  case when I have several builds  biggest benefits  of the  same workflow stay idle in the list awaiting the user input  Multibranch Pipeline and Jenkinsfile is that jenkins jobs are automatically created .

  However, the only way I  would expectr my workflow 've seen  to  discard older builds if the newer  be able to add a  build  has reached  parameter to  the  same stage  job is by manually configuring it .  

But I cannot succeed that goal.

If I
My  use  the workflow like  case is this :
{code}
stage title: 'DevBuild' Project A ( is a Multibranch Pipeline ) builds ,  concurrency: 1
// do build
stage title: 'Integration'
 and as part of its pipeline ,  concurrency: 1
input message:
 triggers Project B, also a MultiBranch Pipeline.  I  ' Proceed?'
// do integration
{code}
then the very first build enters 'Integration' stage and pauses
d like Project A to pass some information along to Project B  for  user input. The other newer builds may superseed each other, but there is always the last build that gets  it  to  'Integration' stage and waits until the very first  use in its  build  completes (because it cannot enter stage Integration) .

  Specifically, I  would 'd  like  the newer build  Project A  to  discard  identify itself to Project B so that I don't have to hard code  the  older build which waits  "Upstream Project Name" in Project B  for  user input  use  in  this case,  the CopyArtifacts step.  This allows for looser coupling of build jobs  so that  newer build  I  can  be decided by the user  insert jobs into my overall pipeline much easier .

Is it possible to implement such a scenario?

Thank you Thanks

michael.scharp@fmr.com (JIRA)

unread,
Feb 4, 2016, 12:32:02 PM2/4/16
to jenkinsc...@googlegroups.com
Michael Scharp updated an issue
I apologize if this feature is already present, but I've googled and read through the documentation and haven't been able to find out how to do this.

One of the biggest benefits of the Multibranch Pipeline and Jenkinsfile is that jenkins jobs are automatically created.  However, the only way I've seen to be able to add a build parameter to the job is by manually configuring it.

My use case is this:

Project A ( is a Multibranch Pipeline ) builds, and as part of its pipeline, triggers Project B, also a MultiBranch Pipeline.  I'd like Project A to pass some information along to Project B for it to use in its build.  Specifically, I'd like Project A to identify itself to Project B so that I don't have to hard code the "Upstream Project Name" in Project B for use in the CopyArtifacts step.  This allows for looser coupling of build jobs so that I can insert jobs into my overall pipeline much easier.

I'm not sure if different types of build parameters are harder to support, but for now, the String build parameter would be sufficient.

Acceptance Criteria:
# 1. DSL to support adding scripted build parameters via Jenkinsfile
# 2. Supported build parameters are: String
# 3. Jenkins UI should pick up build parameters and allow for manual entry when job triggered manually
# 4. TOO: Other build parameter types

Thanks

michael.scharp@fmr.com (JIRA)

unread,
Feb 4, 2016, 12:33:01 PM2/4/16
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Feb 18, 2016, 9:25:03 AM2/18/16
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Not A Defect
 

See Snippet Generator for the properties step.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Not A Defect

michael.scharp@fmr.com (JIRA)

unread,
Feb 18, 2016, 11:01:03 AM2/18/16
to jenkinsc...@googlegroups.com
Michael Scharp commented on New Feature JENKINS-32780
 
Re: Parameterize Multibranch Pipeline via Jenkinsfile

Ok. I attempted to use the properties step, but all it gives you is the "what" and not the how/where to use it, which in my case, then produced an error. I'll try again and post results.

michael.scharp@fmr.com (JIRA)

unread,
Feb 18, 2016, 11:57:01 AM2/18/16
to jenkinsc...@googlegroups.com

Ok, maybe there is a defect or I am doing something wrong. Here is my setup:

Jenkinsfile

node() {
    properties [[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
                      [$class: 'ParametersDefinitionProperty',
                       parameterDefinitions: [[$class: 'StringParameterDefinition',
                                     defaultValue: 'asdf', description: '',
                                     name: 'SET_ME']]]]
echo "hello"
}

I've also tried it with the properties section outside of the node. Both attempts produced this error:

groovy.lang.MissingPropertyException: No such property: properties for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:62)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:185)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:23)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:17)

michael.scharp@fmr.com (JIRA)

unread,
Feb 18, 2016, 12:01:01 PM2/18/16
to jenkinsc...@googlegroups.com
Michael Scharp edited a comment on New Feature JENKINS-32780
Jenkins: 1.638
Pipeline: 1.13
Ok, maybe there is a defect or I am doing something wrong.  Here is my setup:

Jenkinsfile

{code:java}

node() {
    properties [[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
                      [$class: 'ParametersDefinitionProperty',
                       parameterDefinitions: [[$class: 'StringParameterDefinition',
                                     defaultValue: 'asdf', description: '',
                                     name: 'SET_ME']]]]
echo "hello"
}
{code}


I've also tried it with the properties section outside of the node.  Both attempts produced this error:

groovy.lang.MissingPropertyException: No such property: properties for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:62)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:185)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:23)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:17)

o.v.nenashev@gmail.com (JIRA)

unread,
Feb 22, 2016, 6:03:01 AM2/22/16
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Feb 22, 2016, 10:48:02 AM2/22/16
to jenkinsc...@googlegroups.com

michael.scharp@fmr.com (JIRA)

unread,
Feb 23, 2016, 3:25:03 PM2/23/16
to jenkinsc...@googlegroups.com

Ok, I've resolved the issue I was encountering... indeed it was related to JENKINS-29711

melvyn.romero@gmail.com (JIRA)

unread,
Jul 8, 2016, 3:56:01 PM7/8/16
to jenkinsc...@googlegroups.com

Hi Michael, can you post the solution to this issue, thanks.

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

michael.scharp@fmr.com (JIRA)

unread,
Jul 11, 2016, 11:59:03 AM7/11/16
to jenkinsc...@googlegroups.com

Sure.


properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'StringParameterDefinition', defaultValue: '', description: 'Some Description', name : 'MY_PARAM'], [$class: 'StringParameterDefinition', defaultValue: '', description: 'Some Description', name: 'MY_PARAM2']]]])
Reply all
Reply to author
Forward
0 new messages