jobs/updateSrcRev: added cloning of the repository (was missing)
Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
parent
3ff3dc9435
commit
c4d49cdc0e
|
|
@ -32,6 +32,7 @@ pipeline {
|
||||||
common = load "./jobs/Jenkinsfile_Common"
|
common = load "./jobs/Jenkinsfile_Common"
|
||||||
|
|
||||||
handleCleanBuild(common)
|
handleCleanBuild(common)
|
||||||
|
common.gitCheckout("${env.YOCTO_REPO_URL}", "${params.BUILD_BRANCH}", "${env.YOCTO_REPO_DIR}", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -39,14 +40,14 @@ pipeline {
|
||||||
stage('Update') {
|
stage('Update') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
updateTheSourceRevisions(common, "${params.BUILD_BRANCH}")
|
updateTheSourceRevisions(common, "${env.YOCTO_REPO_DIR}", "${params.BUILD_BRANCH}")
|
||||||
commitAndPushTheChanges(common)
|
commitAndPushTheChanges(common, "${env.YOCTO_REPO_DIR}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
common.cleanupRepository("./")
|
common.cleanupRepository("${env.YOCTO_REPO_DIR}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,36 +84,40 @@ def handleCleanBuild(commonHelpers) {
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
def updateTheSourceRevisions(commonHelpers, theBranch) {
|
def updateTheSourceRevisions(commonHelpers, repoDir, theBranch) {
|
||||||
commonHelpers.gitUpdateSubmodulesCheckoutBranch(theBranch, true, true)
|
dir(repoDir) {
|
||||||
commonHelpers.printSubmoduleStatus(true)
|
commonHelpers.gitUpdateSubmodulesCheckoutBranch(theBranch, true, true)
|
||||||
|
commonHelpers.printSubmoduleStatus(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
def commitAndPushTheChanges(commonHelpers) {
|
def commitAndPushTheChanges(commonHelpers, repoDir) {
|
||||||
def commitMsg = "srcrev: updated source revisions by Jenkins Job"
|
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) {
|
dir(repoDir) {
|
||||||
def itemFindCmd = "git status | grep \"modified:\" | grep -v coreos | cut -d':' -f2 | sed -e 's/^[ ]*//' | cut -d' ' -f1"
|
if(sh(returnStdout: true, script: "git status | grep \"modified:\" | grep -v coreos | wc -l").toInteger() != 0) {
|
||||||
def changedItems = sh(returnStdout: true, script: "${itemFindCmd}")
|
def itemFindCmd = "git status | grep \"modified:\" | grep -v coreos | cut -d':' -f2 | sed -e 's/^[ ]*//' | cut -d' ' -f1"
|
||||||
sh(label: "Stage tracked and changed git files", returnStdout: true, script: "git add ${changedItems}")
|
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) {
|
if(params.DRY_RUN) {
|
||||||
println "DRY RUN: commit message = '${commitMsg}'\n changes = ${changedItems}"
|
println "DRY RUN: commit message = '${commitMsg}'\n changes = ${changedItems}"
|
||||||
sh(script: """
|
sh(script: """
|
||||||
git reset HEAD * > /dev/null
|
git reset HEAD * > /dev/null
|
||||||
git checkout * > /dev/null
|
git checkout * > /dev/null
|
||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println "ToDo: commit and push the changes"
|
println "ToDo: commit and push the changes"
|
||||||
//NOTE: The following code snippet may help...
|
//NOTE: The following code snippet may help...
|
||||||
//def theCredentials = getGitCredentialID()
|
//def theCredentials = getGitCredentialID()
|
||||||
//sshagent (credentials: [theCredentials]) {
|
//sshagent (credentials: [theCredentials]) {
|
||||||
// sh(label: "Commit and push changes", returnStdout: true, script: """
|
// sh(label: "Commit and push changes", returnStdout: true, script: """
|
||||||
// git commit -m "${commitMsg}"
|
// git commit -m "${commitMsg}"
|
||||||
// git push
|
// git push
|
||||||
// """)
|
// """)
|
||||||
//}
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue