Home > Back-end >  jenkinsfile - how to concatenate two variables in a stage
jenkinsfile - how to concatenate two variables in a stage

Time:11-10

In the jenkinsfile I have started using environment context in one of the stage and now there is a requirement to concatenate with one static value which is 'grafana-' with the variable declared in the Jenkins configuration and assign the output to a new variable. CLUSTER_NAME is the key/variable and value is TEST under jenkins > configuration Tried different ways but couldn't get value for variable CLUSTER_NAME

environment {
               def INSTANCE_NAME='grafana-${env.CLUSTER_NAME}'
           }

CodePudding user response:

Use doudble quotes instead of single quotes.

environment {
    def INSTANCE_NAME = "grafana-${env.CLUSTER_NAME}"
}
  • Related