[JIRA] (JENKINS-46542) External way to set default parameter values for a pipeline job

17 views
Skip to first unread message

svanoort@cloudbees.com (JIRA)

unread,
Apr 12, 2018, 12:12:02 PM4/12/18
to jenkinsc...@googlegroups.com
Sam Van Oort updated an issue
 
Jenkins / Story JENKINS-46542
External way to set default parameter values for a pipeline job
Change By: Sam Van Oort
Priority: Blocker Minor
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

svanoort@cloudbees.com (JIRA)

unread,
Apr 12, 2018, 12:16:01 PM4/12/18
to jenkinsc...@googlegroups.com
Sam Van Oort commented on Story JENKINS-46542
 
Re: External way to set default parameter values for a pipeline job

Herbert Fischer This is a completely reasonable enhancement but please reserve Critical priority for features that are needed to use Pipelines in a standard, common way. For bugs, Critical would be something that brings Jenkins down completely or renders core functionality unusable (i.e. a regression meaning that no Pipelines run, or for an SCM, you can't check out code ever), so keep that in mind. Thanks!

This is a pretty specialized usage you're describing, so I'm adjusting priority accordingly... but also voting for the issue myself because in my Jenkins usage I need default parameter handling and have been annoyed by the need for code hacks to work around it.

steph@chuci.org (JIRA)

unread,
Apr 14, 2018, 11:17:03 AM4/14/18
to jenkinsc...@googlegroups.com

Another +1 for this feature, my use case is different but I'd say the usage isn't that specialised: I have a simple build CI/CD pipeline for a F/OSS project however the artifact it builds needs to be uploaded somewhere: for me this is a cloud object store. I do not want to leak object store buckets or paths that are specific to my companies' implementation of this project. I'd like to do it all within the same pipeline but as I can't I'm looking at the workflow plugin instead, simply to do the upload.

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 4:23:03 AM8/16/18
to jenkinsc...@googlegroups.com

My solution is a following:

at jenkinsfile.pipeline.properties:

 

 distribution_property=testing
 tag_property=RanByJenkins_FromPropertiesFile

 

at Jenkinsfile :

node {

   def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"
   def distribution= props['distribution_property'] 
   def tag= props['tag_property']
   properties([
      parameters([ 
         string(name: 'distribution', defaultValue: 'testing', description: 'apt distribution'),
         string(name: 'tag', defaultValue: 'RanByJenkins_default', description: 'just a tag'),
      ])
   ])
   echo "distribution: $distribution"
   echo "tag: $tag"

 

Is that what you mean?

 

This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 4:23:04 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
My solution is a following:

{{at jenkinsfile.pipeline.properties:}}

 
{code:java}
distribution_property=testing
tag_property=RanByJenkins_FromPropertiesFile{code}
 

{{at Jenkinsfile :}}
{code:java}

node {

   def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"
   def distribution= props['distribution_property']
   def tag= props['tag_property']
   properties([
      parameters([
         string(name: 'distribution', defaultValue: 'testing', description: 'apt distribution'),
         string(name: 'tag', defaultValue: 'RanByJenkins_default', description: 'just a tag'),
      ])
   ])
   echo "distribution: $distribution"
   echo "tag: $tag"
{code}

 

Is that what you mean?

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 4:24:01 AM8/16/18
to jenkinsc...@googlegroups.com

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 4:25:02 AM8/16/18
to jenkinsc...@googlegroups.com

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 4:25:03 AM8/16/18
to jenkinsc...@googlegroups.com

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 4:26:02 AM8/16/18
to jenkinsc...@googlegroups.com

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 8:18:04 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
My solution is a following:

{{at jenkinsfile.pipeline.properties:}}
{code:java}
distribution_property=testing
tag_property=RanByJenkins_FromPropertiesFile{code}
 {{at Jenkinsfile :}}
{code:java}
node {

   def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"

   def distribution= props['distribution_property']
   def tag= props['tag_property']

   properties([
      parameters([
         string(name: 'distribution', defaultValue: 'testing', description: 'apt distribution'),
         string(name: 'tag', defaultValue: 'RanByJenkins_default', description: 'just a tag')
      ])
   ])

   echo "distribution: $distribution"
   echo "tag: $tag"
{code}
 
Values from properties file will not be overriden by default values NOR by values from UI!!!
To make values overridable omit them from properties file.
Then default will be taken or value from GUI - if it was changed from
the default .

Is that what you mean?

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 8:18:04 AM8/16/18
to jenkinsc...@googlegroups.com
Then default will be taken or value from GUI - if it was changed from default

Is that what you mean?

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 8:25:02 AM8/16/18
to jenkinsc...@googlegroups.com
Then default will be taken or value from GUI - if it was changed from the default.

Is that what you
mean need ?

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 8:57:04 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv updated an issue
 
Change By: Bentzy Sagiv
Comment:
My solution is a following:

{{at jenkinsfile.pipeline.properties:}}
{code:java}
distribution_property=testing
tag_property=RanByJenkins_FromPropertiesFile{code}
 {{at Jenkinsfile :}}
{code:java}
node {

   def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"

   def distribution= props['distribution_property']
   def tag= props['tag_property']

   properties([
      parameters([
         string(name: 'distribution', defaultValue: 'testing', description: 'apt distribution'),
         string(name: 'tag', defaultValue: 'RanByJenkins_default', description: 'just a tag')
      ])
   ])

   echo "distribution: $distribution"
   echo "tag: $tag"
{code}
 
Values from properties file will not be overriden by default values NOR by values from UI!!!
To make values overridable omit them from properties file.
Then default will be taken or value from GUI - if it was changed from the default.

Is that what you need?

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:39:04 AM8/16/18
to jenkinsc...@googlegroups.com

at jenkinsfile.pipeline.properties:

 

distribution_property=testing
tag_property=RanByJenkins_FromPropertiesFile

 

at Jenkinsfile :

 

node {
  def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"
  def distribution= props['distribution_property'] 
  def tag= props['tag_property'
]
  properties([
    parameters([ 
      string(name: 'distribution', defaultValue: "$distribution", description: 'apt distribution'),
      string(name: 'tag', defaultValue: "$tag", description: 'just a tag')
    ])
 ])
 echo "distribution: ${params.distribution}"
 echo "tag: ${params.tag}"
...
 

 

 

Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:39:05 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:39:05 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
Thats what I do:

at jenkinsfile.pipeline.properties:

 

{code:java}
distribution_property=testing
tag_property=RanByJenkins_FromPropertiesFile {code}

 

at Jenkinsfile :

 

{code:java}
node {
  def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"
  def distribution= props['distribution_property']
  def tag= props['tag_property']
  properties([
    parameters([
      string(name: 'distribution', defaultValue: "$distribution", description: 'apt distribution'),
      string(name: 'tag', defaultValue: "$tag", description: 'just a tag')
    ])
])
echo "distribution: ${params.distribution}"
echo "tag: ${params.tag}"
...
 
{code}
 

 

Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:40:01 AM8/16/18
to jenkinsc...@googlegroups.com

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:42:03 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
Thats what I do:

at jenkinsfile.pipeline.properties:
{code:java}
 distribution_property=testing tag_property=RanByJenkins_FromPropertiesFile{code}
 

at Jenkinsfile :

 
{code:java}
  node {
def props = readProperties file: " <YOUR_PATH> /jenkinsfile.pipeline.properties"

def distribution= props['distribution_property']

def tag= props['tag_property']
properties([
parameters([
string(name: 'distribution', defaultValue: "$distribution" 'testing' , description: 'apt distribution'),
string(name: 'tag', defaultValue: "$tag" 'RanByJenkins_default' , description: 'just a tag')
])
])
echo "distribution: $ {params. distribution } "
echo "tag: $ {params. tag } "
...   {code}
 

 

Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:43:02 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
Thats what I do:

at jenkinsfile.pipeline.properties:
{code:java}
 distribution_property=testing tag_property=RanByJenkins_FromPropertiesFile{code}
 

at Jenkinsfile :

 
{code:java}
node {
  def props = readProperties file: "/jenkinsfile.pipeline.properties"


  def distribution= props['distribution_property']

  def tag= props['tag_property']
  properties([
    parameters([
     string(name: 'distribution', defaultValue: 'testing', description: 'apt distribution'),
     string(name: 'tag', defaultValue: 'RanByJenkins_default', description: 'just a tag')
   ])
])
echo "distribution: $distribution"
echo "tag: $tag"
...{code}
 


 

Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:44:02 AM8/16/18
to jenkinsc...@googlegroups.com

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:44:02 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
Thats what I do:

at jenkinsfile.pipeline.properties:
{code:java}
 distribution_property=testing tag_property=RanByJenkins_FromPropertiesFile{code}
at Jenkinsfile:
{code:java}
node {
  def props = readProperties file: " <YOUR_PATH> /jenkinsfile.pipeline.properties"


  def distribution= props['distribution_property']

  def tag= props['tag_property']
  properties([
    parameters([
     string(name: 'distribution', defaultValue: 'testing', description: 'apt distribution'),
     string(name: 'tag', defaultValue: 'RanByJenkins_default', description: 'just a tag')
   ])
])
echo "distribution: $distribution"
echo "tag: $tag"
...{code}
Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.

 

bentzy.sagiv@gmail.com (JIRA)

unread,
Aug 16, 2018, 9:45:02 AM8/16/18
to jenkinsc...@googlegroups.com
Bentzy Sagiv edited a comment on Story JENKINS-46542
Thats what I do:

at jenkinsfile.pipeline.properties:
{code:java}
 distribution_property=testing tag_property=RanByJenkins_FromPropertiesFile{code}
at Jenkinsfile:
{code:java}
node {
  def props = readProperties file: "<YOUR_PATH>/jenkinsfile.pipeline.properties"

  def distribution= props['distribution_property']

  def tag= props['tag_property']
  properties([
    parameters([
     string(name: 'distribution', defaultValue: 'testing' "$distribution" , description: 'apt distribution'),
     string(name: 'tag', defaultValue:
'RanByJenkins_default' "$tag" , description: 'just a tag')

   ])
])
echo "distribution: $distribution"
echo "tag: $tag"
...{code}
Default values are took from properties file.
Default values can be overriden at UI.
Values at UI are cached from last run.
To restore defaults (from properties file) for next run just delete cached values.

 

katyaskok@gmail.com (JIRA)

unread,
May 23, 2019, 8:51:04 AM5/23/19
to jenkinsc...@googlegroups.com

I have the same problem as in the previous comment.

How can I delete cached values?

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

ceztko@gmail.com (JIRA)

unread,
Mar 24, 2020, 6:18:05 AM3/24/20
to jenkinsc...@googlegroups.com

This issue mentions EnvInject and pipeline in the tags so I expect the poster wants to modify the the default value of the parameters in a pipeline project, possibly stored as a Jenkinsfile in CSM, directly in the Jenkins project where it is configured. My tests show that is already possible in a similar way the user Bentzy Sagiv is performing and precisely using the EnvInject plugin. Try the example pipeline and setup described in this Stack Overflow post .

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

ceztko@gmail.com (JIRA)

unread,
Mar 24, 2020, 6:19:03 AM3/24/20
to jenkinsc...@googlegroups.com
Francesco Pretto edited a comment on Story JENKINS-46542
This issue mentions [EnvInject|https://plugins.jenkins.io/envinject/] and {{pipeline}} in the tags so I expect the poster wants to dynamically modify the the default value of the parameters in a pipeline project, possibly stored as a {{Jenkinsfile}} in CSM, directly in the Jenkins project where it is configured. My tests show that is already possible in a similar way the user [~bentzy] is performing and precisely using creating an environment with the EnvInject plugin. Try the example pipeline and setup described in this Stack Overflow [post|https://stackoverflow.com/a/60828812/213871] .

ceztko@gmail.com (JIRA)

unread,
Mar 24, 2020, 6:19:03 AM3/24/20
to jenkinsc...@googlegroups.com
Francesco Pretto edited a comment on Story JENKINS-46542
This issue mentions [EnvInject|https://plugins.jenkins.io/envinject/] and {{pipeline}} in the tags so I expect the poster wants to dynamically modify the the default value of the parameters in a pipeline project, possibly stored as a {{Jenkinsfile}} in CSM, directly in the Jenkins project where it is configured. My tests show that is already possible in a similar way the user [~bentzy] is performing and precisely creating an environment with the EnvInject plugin. Try the example pipeline and setup described in this Stack Overflow [post|https://stackoverflow.com/a/60828812/213871] .
Reply all
Reply to author
Forward
0 new messages