Reputation: 1478
I'm using Jenkins 2.150.3 and after installing all the suggested plugins I've created a new "pipeline" project.
Just for test I've created a script like the following
node {
stage('Checkout') {
git branch: 'develop',
credentialsId: 'myCredentials',
url: 'https://urlToMyRepo.git'
sh 'git config --list'
//sh 'echo `env`'
echo sh(script: 'env', returnStdout: true)
}
}
In this script, after the checkout (that is completed successfully) I list all the environment variables, but even though I've installed the Git plugin, all its environment variables are not set.
What I'm doing wrong?
Upvotes: 0
Views: 574
Reputation: 12255
You can use TreeMap from git:
gitVar = git(branch: branchName, credentialsId: credential, url: "repository.git")
echo gitVar.GIT_COMMIT
Fields:
GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME
GIT_BRANCH
GIT_COMMIT
GIT_COMMITTER_EMAIL
GIT_COMMITTER_NAME
GIT_LOCAL_BRANCH
GIT_PREVIOUS_COMMIT
GIT_PREVIOUS_SUCCESSFUL_COMMIT
GIT_URL
Upvotes: 2