jenkinsfile_update2head: added info about triggered user to commit msg

BugzID: 73574
Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmueller 2021-07-06 11:57:50 +02:00 committed by Gitea
parent d34fa204e1
commit 32ab6f42ca
1 changed files with 8 additions and 17 deletions

View File

@ -16,7 +16,7 @@ pipeline {
} }
options { options {
timeout(time: 8, unit: 'HOURS') timeout(time: 1, unit: 'HOURS')
buildDiscarder( buildDiscarder(
logRotator(numToKeepStr: '5', logRotator(numToKeepStr: '5',
daysToKeepStr: '5', daysToKeepStr: '5',
@ -72,21 +72,12 @@ def printJobParameters() {
def prepareUpdate() { def prepareUpdate() {
sh 'git submodule init' // init submodules used if first checkout sh 'git submodule init' // init submodules used if first checkout
def userId = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId() def userId = "${currentBuild.getBuildCauses()[0].userId}"
println "userId = ${userId}" def userName = "${currentBuild.getBuildCauses()[0].userName}"
env.TRIGGERED_USER = "${userName} (userId=${userId})"
def userIdCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')[0] def notNmUpdate = "${!params.UPDATE_NM_PARTS}"
println userIdCause def notCommunityUpdate = "${!params.UPDATE_COMMUNITY_PARTS}"
def buildCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
println "userName: ${buildCause.userName}"
def triggerDescription = "${currentBuild.getBuildCauses()[0].shortDescription}"
def triggerUserId = "${currentBuild.getBuildCauses()[0].userId}"
println "description: ${triggerDescription} ; userId: ${triggerUserId}"
def notNmUpdate = "${!params.BUILD_FROM_DEV_IMAGE}"
def notCommunityUpdate = "${!params.BUILD_FROM_DEV_IMAGE}"
if(notNmUpdate.toBoolean() && notCommunityUpdate.toBoolean()) { if(notNmUpdate.toBoolean() && notCommunityUpdate.toBoolean()) {
error("Nothing to update selected - both parameters are false") error("Nothing to update selected - both parameters are false")
} }
@ -106,9 +97,9 @@ def updateSubmodules(isNmUpdate, isCommunityUpdate) {
def commitChanges(isNmUpdate, isCommunityUpdate) { def commitChanges(isNmUpdate, isCommunityUpdate) {
String updatedLayers = "" String updatedLayers = ""
if(isNmUpdate) { updatedLayers += "netmoudle"} if(isNmUpdate) { updatedLayers += "netmodule"}
if(isNmUpdate && isCommunityUpdate) { updatedLayers += " and " } if(isNmUpdate && isCommunityUpdate) { updatedLayers += " and " }
if(isCommunityUpdate) { updatedLayers += "community" } if(isCommunityUpdate) { updatedLayers += "community" }
sh(script: "git add -u") sh(script: "git add -u")
sh(script: "git commit -m \"submodules: updated ${updatedLayers} hashes\" && git push") sh(script: "git commit -m \"submodules: updated ${updatedLayers} hashes, triggered by ${env.TRIGGERED_USER}\" && git push")
} }