mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-03 15:02:35 +02:00
fail in case git add or git commit fails during artifactSetVersion (#1491)
* fail in case git add or git commit fails during artifactSetVersion * check if there is a git config on os level * better error message in case no user name/mail are configured Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com> Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com>
This commit is contained in:
parent
37a6d456fe
commit
803071f143
@ -185,12 +185,29 @@ void call(Map parameters = [:], Closure body = null) {
|
||||
|
||||
def gitConfig = []
|
||||
|
||||
if(config.gitUserEMail) gitConfig.add("-c user.email=\"${config.gitUserEMail}\"")
|
||||
if(config.gitUserName) gitConfig.add("-c user.name=\"${config.gitUserName}\"")
|
||||
if(config.gitUserEMail) {
|
||||
gitConfig.add("-c user.email=\"${config.gitUserEMail}\"")
|
||||
} else {
|
||||
// in case there is no user.email configured on project level we might still
|
||||
// be able to work in case there is a configuration available on plain git level.
|
||||
if(sh(returnStatus: true, script: 'git config user.email') != 0) {
|
||||
error 'No git user.email configured. Neither via project config nor on plain git level.'
|
||||
}
|
||||
}
|
||||
if(config.gitUserName) {
|
||||
gitConfig.add("-c user.name=\"${config.gitUserName}\"")
|
||||
} else {
|
||||
// in case there is no user.name configured on project level we might still
|
||||
// be able to work in case there is a configuration available on plain git level.
|
||||
if (sh(returnStatus: true, script: 'git config user.name') != 0) {
|
||||
error 'No git user.name configured. Neither via project config nor on plain git level.'
|
||||
}
|
||||
}
|
||||
gitConfig = gitConfig.join(' ')
|
||||
|
||||
try {
|
||||
sh """#!/bin/bash
|
||||
set -e
|
||||
git add . --update
|
||||
git ${gitConfig} commit -m 'update version ${newVersion}'
|
||||
git tag ${config.tagPrefix}${newVersion}"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user