Details
-
Type:
Improvement
-
Status: Fixed but Unreleased (View Workflow)
-
Priority:
Critical
-
Resolution: Not A Defect
-
Component/s: pipeline-model-definition-plugin
-
Environment:Jenkins: 2.73.3
-
Similar Issues:
Description
Hi,
Currently there is no option to set an environment variable based on boolean value within the environment directive. I think it is crucial to implement support for something like this:
pipeline{ agent any environment { /*Option1*/ condition $params.some_bool_parameter{CC = "1"} /* Option2 variable will be set to "1" only if the boolean value is true */ CC = $params.some_bool_parameter : "1" /* This is currently supported */ CC = $params.some_non_bool_parameter } }
You can do something like:
CC = "${params.some_bool_parameter ? '1' : ''}"
Which will set CC to 1 if some_bool_parameter is true, and will set it to '' otherwise. If that's not sufficient and you need to be able to have the variable be unset completely, you may need to use Scripted Pipeline instead.