Merge branch 'develop' into ansible-instance
This commit is contained in:
commit
ff7b28774a
|
|
@ -32,6 +32,7 @@ pipeline {
|
|||
common = load "./jobs/Jenkinsfile_Common"
|
||||
|
||||
handleCleanBuild(common)
|
||||
common.gitCheckout("${env.YOCTO_REPO_URL}", "${params.BUILD_BRANCH}", "${env.YOCTO_REPO_DIR}", true, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,14 +40,14 @@ pipeline {
|
|||
stage('Update') {
|
||||
steps {
|
||||
script {
|
||||
updateTheSourceRevisions(common, "${params.BUILD_BRANCH}")
|
||||
commitAndPushTheChanges(common)
|
||||
updateTheSourceRevisions(common, "${env.YOCTO_REPO_DIR}", "${params.BUILD_BRANCH}")
|
||||
commitAndPushTheChanges(common, "${env.YOCTO_REPO_DIR}")
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
common.cleanupRepository("./")
|
||||
common.cleanupRepository("${env.YOCTO_REPO_DIR}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -83,36 +84,36 @@ def handleCleanBuild(commonHelpers) {
|
|||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def updateTheSourceRevisions(commonHelpers, theBranch) {
|
||||
commonHelpers.gitUpdateSubmodulesCheckoutBranch(theBranch, true, true)
|
||||
commonHelpers.printSubmoduleStatus(true)
|
||||
def updateTheSourceRevisions(commonHelpers, repoDir, theBranch) {
|
||||
dir(repoDir) {
|
||||
commonHelpers.gitUpdateSubmodulesCheckoutBranch(theBranch, true, true)
|
||||
commonHelpers.printSubmoduleStatus(true)
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def commitAndPushTheChanges(commonHelpers) {
|
||||
def commitAndPushTheChanges(commonHelpers, repoDir) {
|
||||
def commitMsg = "srcrev: updated source revisions by Jenkins Job"
|
||||
|
||||
if(sh(returnStdout: true, script: "git status | grep \"modified:\" | grep -v coreos | wc -l").toInteger() != 0) {
|
||||
def itemFindCmd = "git status | grep \"modified:\" | grep -v coreos | cut -d':' -f2 | sed -e 's/^[ ]*//' | cut -d' ' -f1"
|
||||
def changedItems = sh(returnStdout: true, script: "${itemFindCmd}")
|
||||
sh(label: "Stage tracked and changed git files", returnStdout: true, script: "git add ${changedItems}")
|
||||
dir(repoDir) {
|
||||
if(sh(returnStdout: true, script: "git status | grep \"modified:\" | grep -v coreos | wc -l").toInteger() != 0) {
|
||||
def itemFindCmd = "git status | grep \"modified:\" | grep -v coreos | cut -d':' -f2 | sed -e 's/^[ ]*//' | cut -d' ' -f1"
|
||||
def changedItems = sh(returnStdout: true, script: "${itemFindCmd}")
|
||||
sh(label: "Stage tracked and changed git files", returnStdout: true, script: "git add ${changedItems}")
|
||||
|
||||
if(params.DRY_RUN) {
|
||||
println "DRY RUN: commit message = '${commitMsg}'\n changes = ${changedItems}"
|
||||
sh(script: """
|
||||
git reset HEAD * > /dev/null
|
||||
git checkout * > /dev/null
|
||||
""")
|
||||
}
|
||||
else {
|
||||
println "ToDo: commit and push the changes"
|
||||
//NOTE: The following code snippet may help...
|
||||
//def theCredentials = getGitCredentialID()
|
||||
//sshagent (credentials: [theCredentials]) {
|
||||
// sh(label: "Commit and push changes", returnStdout: true, script: """
|
||||
// git commit -m "${commitMsg}"
|
||||
// git push
|
||||
// """)
|
||||
//}
|
||||
if(params.DRY_RUN) {
|
||||
println "DRY RUN: commit message = '${commitMsg}'\n changes = ${changedItems}"
|
||||
sh(script: "git reset HEAD > /dev/null")
|
||||
}
|
||||
else {
|
||||
def theCredentials = commonHelpers.getGitCredentialID()
|
||||
sshagent (credentials: [theCredentials]) {
|
||||
println "Commit and Push changes; message = '${commitMsg}'\nchanges = ${changedItems}"
|
||||
sh(label: "Commit and push changes", returnStdout: true, script: """
|
||||
git commit -m "${commitMsg}"
|
||||
git push
|
||||
""")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue