Skip to content

Instantly share code, notes, and snippets.

@starwarsfan
Created December 18, 2020 21:31
Show Gist options
  • Save starwarsfan/f8e35ef691fd2d3968af9cac842ce4e9 to your computer and use it in GitHub Desktop.
Save starwarsfan/f8e35ef691fd2d3968af9cac842ce4e9 to your computer and use it in GitHub Desktop.
Jenkins declarative pipeline env var definition
environment {
DEVELOP_TAG = "Build${BUILD_NUMBER}"
RELEASE_TAG = sh(
script: "printf \$(grep CLIENT_VERSION_MAJOR CMakeLists.txt | head -n1 | cut -d ' ' -f2 | sed 's/)//g' | tr -d '\\n' | tr -d '\\r').\$(grep CLIENT_VERSION_MINOR CMakeLists.txt | head -n1 | cut -d ' ' -f2 | sed 's/)//g' | tr -d '\\n' | tr -d '\\r').\$(grep CLIENT_VERSION_REVISION CMakeLists.txt | head -n1 | cut -d ' ' -f2 | sed 's/)//g' | tr -d '\\n' | tr -d '\\r') | sed 's/ //g'",
returnStdout: true
)
GIT_TAG_TO_USE = "${DEVELOP_TAG}"
GIT_COMMIT_SHORT = sh(
script: "printf \$(git rev-parse --short ${GIT_COMMIT})",
returnStdout: true
)
CURRENT_DATE = sh(
script: "printf \"\$(date '+%F %T')\"",
returnStdout: true
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment