Вы можете получить информацию, используя return TreeMap
из git
:
try {
d = git(branch: branchName, credentialsId: credential, url: "${gitLabServer}/${projectName}/${repo}.git")
echo d["GIT_COMMIT"]
} catch (Exception e) {
echo "${e}"
}
Поля:
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
Обновление:
def treeMapData
pipeline {
agent any
stages {
stage ('Get Commit') {
steps{
script{
try {
treeMapData = git(branch: branchName, credentialsId: credential, url: "${gitLabServer}/${projectName}/${repo}.git")
echo treeMapData["GIT_COMMIT"]
} catch (Exception e) {
echo "${e}"
}
}
}
}
}
}
или
def treeMapData
node {
stage ('Build') {
try {
treeMapData = git(branch: branchName, credentialsId: credential, url: "${gitLabServer}/${projectName}/${repo}.git")
echo treeMapData["GIT_COMMIT"]
} catch (Exception e) {
echo "${e}"
}
}
}