Jenkins parameters default to env variable?
6,211
You need to use double quotes instead of single quotes. Single-quoted strings don't perform string interpolation.
For instance:
parameters {
string(
name: 'DEPLOY_BUILD_NUMBER',
defaultValue: "${BUILD_NUMBER}",
description: 'Fresh Build and Deploy OR Deploy Previous Build Number'
)
}
Related videos on Youtube
Author by
roy
Updated on September 18, 2022Comments
-
roy over 1 year
I am trying to crate parameters field which is default to current build no.
parameters { string( name: 'DEPLOY_BUILD_NUMBER', defaultValue: '${BUILD_NUMBER}', description: 'Fresh Build and Deploy OR Deploy Previous Build Number' ) }
But it looks like the assignment of
BUILD_NUMBER
env var to parameterDEPLOY_BUILD_NUMBER
is not happening.even following one didn't help
steps { script { if (params.DEPLOY_BUILD_NUMBER == null){ DEPLOY_BUILD_NUMBER = env.BUILD_NUMBER } } }
Is there any other way to do this ?
-
roy about 5 yearsafter this change,
echo "${DEPLOY_BUILD_NUMBER}"
printsenv.BUILD_NUMBER
. How can I get actual value ofenv.BUILD_NUMBER
, when I refer to${DEPLOY_BUILD_NUMBER}