2

I have ha Jenkins job that has a string input parameter of the build flags for the make command in my Jenkins job. My problem is that some users forget to change the parameter values when we have a release branch. So I want to overwrite the existing string input parameter (or create a new one) that should be used if the job is a release job.

This is the statement I want to add:

If branch "release" then ${params.build_flag} = 'DEBUGSKIP=TRUE'

and the code that is not working is:

pipeline {
agent none


parameters {
    string(name: 'build_flag', defaultValue: 'DEBUGSKIP=TRUE', description: 'Flags to pass to build')   

    If {
       allOf {
            branch "*release*"
            expression {
                ${params.build_flag} = 'DEBUGSKIP=TRUE'
            }
        }
    }else{
    ${params.build_flag} = 'DEBUGSKIP=FALSE'
    }
}

The code above explains what I want to do but I don't know to do it.

Sharky
  • 323
  • 1
  • 3
  • 11

1 Answers1

0

If you can, see if you could use the JENKINS EnvInject Plugin, with your pipeline, using the supported use-case:

Injection of EnvVars defined in the "Properties Content" field of the Job Property

These EnvVars are being injected to the script environment and will be inaccessible via the "env" Pipeline global variable (as in here)

Or writing the right values in a file, and using that file content as "Properties Content" of a downstream job (as shown there).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250