Parameterized build driven by Jenkinsfile

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Parameterized build driven by Jenkinsfile

Craig Barr
In Jenkins you can select "This project is parameterized" and add parameters. My question is simple:
Can this parameter metadata be populated by an alternative version-controlled source?

For example, can I define parameter definitions in my Jenkinsfile so that when I click Build Now it will populate the parameters from this source?
If this is not possible, are they any other suggestions for addressing such a requirement?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parameterized build driven by Jenkinsfile

Jacob Larsen-2

Yes, kind of...

The parameters are hidden in the "properties" structure. They will be applied to the job when it runs, meaning that the first run will not have these parameters defined. If you make your Jenkinsfile robust for undefined parameters, it should be doable, just remember that they will apply to the second build.

/Jacob


On 2017-08-03 04:03, Craig Barr wrote:
In Jenkins you can select "This project is parameterized" and add parameters. My question is simple:
Can this parameter metadata be populated by an alternative version-controlled source?

For example, can I define parameter definitions in my Jenkinsfile so that when I click Build Now it will populate the parameters from this source?
If this is not possible, are they any other suggestions for addressing such a requirement?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ef2112a4-a9a0-36be-c420-b3a5d674acb7%40larsen.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parameterized build driven by Jenkinsfile

Alex Marcon
That's right... to define, it is something like:

    parameters {
        string(name: 'bld', defaultValue: 'full', description: '')
        string(name: 'branch', defaultValue: 'dev', description: '')
    }

you may load some properties from a file and use those variables for defaultValue...

AM

On Thursday, 3 August 2017 04:13:54 UTC-4, Jacob Larsen wrote:

Yes, kind of...

The parameters are hidden in the "properties" structure. They will be applied to the job when it runs, meaning that the first run will not have these parameters defined. If you make your Jenkinsfile robust for undefined parameters, it should be doable, just remember that they will apply to the second build.

/Jacob


On 2017-08-03 04:03, Craig Barr wrote:
In Jenkins you can select "This project is parameterized" and add parameters. My question is simple:
Can this parameter metadata be populated by an alternative version-controlled source?

For example, can I define parameter definitions in my Jenkinsfile so that when I click Build Now it will populate the parameters from this source?
If this is not possible, are they any other suggestions for addressing such a requirement?

Thanks!

O<a href="http://www.rubiconred.com/oracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Foracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH14QFghLfbsj0oYuomq15s12km6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Foracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH14QFghLfbsj0oYuomq15s12km6g&#39;;return true;">racle Excellence Award Specialized Partner of the Year: Middleware, Asia Pacific



<a href="http://www.rubiconred.com/privacy-policy-2/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Fprivacy-policy-2%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFc89WllAglEDevWCX5OkgIhfRJlQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Fprivacy-policy-2%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFc89WllAglEDevWCX5OkgIhfRJlQ&#39;;return true;">Rubicon Red Privacy Policy 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RF3NG5bEBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/839e9a5f-acef-413a-a73b-0e72e6ace741%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parameterized build driven by Jenkinsfile

Craig Barr-2
Thanks Jacob and Alex!

Which version of Jenkins does this work for you on?
I've tried with the following Jenkinsfile on 2.46.1 but no matter how many times I ran, the parameters never showed up in the console.

parameters {

   string(name: 'bld', defaultValue: 'full', description: '')

   string(name: 'branch', defaultValue: 'dev', description: '')

}


node {

   if (getBinding().hasVariable("bld")) {

      echo "SET"

   } else {

      echo "NOTSET"

   }

}


On Friday, 4 August 2017 03:27:44 UTC+10, Alex Marcon wrote:
That's right... to define, it is something like:

    parameters {
        string(name: 'bld', defaultValue: 'full', description: '')
        string(name: 'branch', defaultValue: 'dev', description: '')
    }

you may load some properties from a file and use those variables for defaultValue...

AM

On Thursday, 3 August 2017 04:13:54 UTC-4, Jacob Larsen wrote:

Yes, kind of...

The parameters are hidden in the "properties" structure. They will be applied to the job when it runs, meaning that the first run will not have these parameters defined. If you make your Jenkinsfile robust for undefined parameters, it should be doable, just remember that they will apply to the second build.

/Jacob


On 2017-08-03 04:03, Craig Barr wrote:
In Jenkins you can select "This project is parameterized" and add parameters. My question is simple:
Can this parameter metadata be populated by an alternative version-controlled source?

For example, can I define parameter definitions in my Jenkinsfile so that when I click Build Now it will populate the parameters from this source?
If this is not possible, are they any other suggestions for addressing such a requirement?

Thanks!

O<a href="http://www.rubiconred.com/oracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Foracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH14QFghLfbsj0oYuomq15s12km6g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Foracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH14QFghLfbsj0oYuomq15s12km6g&#39;;return true;">racle Excellence Award Specialized Partner of the Year: Middleware, Asia Pacific



<a href="http://www.rubiconred.com/privacy-policy-2/" style="color:rgb(17,85,204)" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Fprivacy-policy-2%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFc89WllAglEDevWCX5OkgIhfRJlQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Fprivacy-policy-2%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFc89WllAglEDevWCX5OkgIhfRJlQ&#39;;return true;">Rubicon Red Privacy Policy 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e4e728c9-553a-4720-96c7-5ac29bddabb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parameterized build driven by Jenkinsfile

Jacob Larsen-2

Try this:

properties([
    parameters([
        string(name: 'bld', defaultValue: 'full', description: ''),
        string(name: 'branch', defaultValue: 'dev', description: '')
    ])
])

/Jacob

On 2017-08-09 03:54, Craig Barr wrote:
Thanks Jacob and Alex!

Which version of Jenkins does this work for you on?
I've tried with the following Jenkinsfile on 2.46.1 but no matter how many times I ran, the parameters never showed up in the console.

parameters {

   string(name: 'bld', defaultValue: 'full', description: '')

   string(name: 'branch', defaultValue: 'dev', description: '')

}


node {

   if (getBinding().hasVariable("bld")) {

      echo "SET"

   } else {

      echo "NOTSET"

   }

}


On Friday, 4 August 2017 03:27:44 UTC+10, Alex Marcon wrote:
That's right... to define, it is something like:

    parameters {
        string(name: 'bld', defaultValue: 'full', description: '')
        string(name: 'branch', defaultValue: 'dev', description: '')
    }

you may load some properties from a file and use those variables for defaultValue...

AM

On Thursday, 3 August 2017 04:13:54 UTC-4, Jacob Larsen wrote:

Yes, kind of...

The parameters are hidden in the "properties" structure. They will be applied to the job when it runs, meaning that the first run will not have these parameters defined. If you make your Jenkinsfile robust for undefined parameters, it should be doable, just remember that they will apply to the second build.

/Jacob


On 2017-08-03 04:03, Craig Barr wrote:
In Jenkins you can select "This project is parameterized" and add parameters. My question is simple:
Can this parameter metadata be populated by an alternative version-controlled source?

For example, can I define parameter definitions in my Jenkinsfile so that when I click Build Now it will populate the parameters from this source?
If this is not possible, are they any other suggestions for addressing such a requirement?

Thanks!

O<a href="http://www.rubiconred.com/oracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific/" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Foracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH14QFghLfbsj0oYuomq15s12km6g';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Foracle-excellence-award-specialized-partner-of-the-year-middleware-asia-pacific%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH14QFghLfbsj0oYuomq15s12km6g';return true;" moz-do-not-send="true">racle Excellence Award Specialized Partner of the Year: Middleware, Asia Pacific



<a href="http://www.rubiconred.com/privacy-policy-2/" style="color:rgb(17,85,204)" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Fprivacy-policy-2%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFc89WllAglEDevWCX5OkgIhfRJlQ';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.rubiconred.com%2Fprivacy-policy-2%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFc89WllAglEDevWCX5OkgIhfRJlQ';return true;" moz-do-not-send="true">Rubicon Red Privacy Policy 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" onclick="this.href='https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" moz-do-not-send="true">https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" moz-do-not-send="true">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e4e728c9-553a-4720-96c7-5ac29bddabb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0978cc69-5cbe-6737-a7dc-802fc3dc1511%40larsen.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parameterized build driven by Jenkinsfile

R. Tyler Croy
In reply to this post by Craig Barr
(replies inline)

On Wed, 02 Aug 2017, Craig Barr wrote:

> In Jenkins you can select "This project is parameterized" and add
> parameters. My question is simple:
> Can this parameter metadata be populated by an alternative
> version-controlled source?
>
> For example, can I define parameter definitions in my Jenkinsfile so that
> when I click Build Now it will populate the parameters from this source?
> If this is not possible, are they any other suggestions for addressing such
> a requirement?


My pal Liam created a screencast on this topic recently:
    https://www.youtube.com/watch?v=5_tvlaIeQUQ&feature=youtu.be

See also: https://jenkins.io/doc/book/pipeline/jenkinsfile/#parameters


- R. Tyler Croy

------------------------------------------------------
     Code: <https://github.com/rtyler>
  Chatter: <https://twitter.com/agentdero>
     xmpp: [hidden email]

  % gpg --keyserver keys.gnupg.net --recv-key 1426C7DC3F51E16F
------------------------------------------------------

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/20170809212559.4qi4ut3sxo5gbnfz%40blackberry.coupleofllamas.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Parameterized build driven by Jenkinsfile

Craig Barr-2
In reply to this post by Jacob Larsen-2
Thanks Jacob. That worked exactly as I would expect!

On Thu, Aug 10, 2017 at 5:40 AM, Jacob Larsen <[hidden email]> wrote:

Try this:

properties([
    parameters([
        string(name: 'bld', defaultValue: 'full', description: ''),
        string(name: 'branch', defaultValue: 'dev', description: '')
    ])
])

/Jacob


On 2017-08-09 03:54, Craig Barr wrote:
Thanks Jacob and Alex!

Which version of Jenkins does this work for you on?
I've tried with the following Jenkinsfile on 2.46.1 but no matter how many times I ran, the parameters never showed up in the console.

parameters {

   string(name: 'bld', defaultValue: 'full', description: '')

   string(name: 'branch', defaultValue: 'dev', description: '')

}


node {

   if (getBinding().hasVariable("bld")) {

      echo "SET"

   } else {

      echo "NOTSET"

   }

}


On Friday, 4 August 2017 03:27:44 UTC+10, Alex Marcon wrote:
That's right... to define, it is something like:

    parameters {
        string(name: 'bld', defaultValue: 'full', description: '')
        string(name: 'branch', defaultValue: 'dev', description: '')
    }

you may load some properties from a file and use those variables for defaultValue...

AM

On Thursday, 3 August 2017 04:13:54 UTC-4, Jacob Larsen wrote:

Yes, kind of...

The parameters are hidden in the "properties" structure. They will be applied to the job when it runs, meaning that the first run will not have these parameters defined. If you make your Jenkinsfile robust for undefined parameters, it should be doable, just remember that they will apply to the second build.

/Jacob


On 2017-08-03 04:03, Craig Barr wrote:
In Jenkins you can select "This project is parameterized" and add parameters. My question is simple:
Can this parameter metadata be populated by an alternative version-controlled source?

For example, can I define parameter definitions in my Jenkinsfile so that when I click Build Now it will populate the parameters from this source?
If this is not possible, are they any other suggestions for addressing such a requirement?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/eb7dca33-81d0-4b35-9045-0ab521327109%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e4e728c9-553a-4720-96c7-5ac29bddabb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/oRhJRoBgWfc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0978cc69-5cbe-6737-a7dc-802fc3dc1511%40larsen.net.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAOF_U2rK5Wn7Dv6MBsavf%3DjcnCFVa%2Bw%2B_h5b1%2BhRgtUcO7gu0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...