The Git plugin is installed (by default) in my Jenkins, but I cannot get the env variables that must be passed by the Git plugin. I'm looking for:
GIT_COMMIT
GIT_BRANCH
GIT_PREVIOUS_COMMIT
GIT_PREVIOUS_SUCCESSFUL_COMMIT
GIT_URL
etc .. I am using a pipeline job item pointing to a Github repository with a Jenkins file with the following code
stage 'PushToProd'
node {
git url: "https://github.com/username/fakeurl.git"
echo "Starting PushToProd"
sh 'printenv'
sh 'env'
sh 'echo $BRANCH_NAME'
sh 'echo $GIT_COMMIT'
}
I get many environment variables when I use envor printenvrather than Github plugins.
Any tips on how I can get env git env variables in a job?
Refresh . I can easily get enw Git variables when I use the Freestyle project and use the shell step echo $GIT_COMMIT. Still want to know how to make it work using the Jenkinsfile + Pipeline job item.