jenkins: sync binary storage before and after build

Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmueller 2021-05-05 12:03:09 +02:00
parent db60b919eb
commit 9a3028afaa
1 changed files with 22 additions and 15 deletions

37
Jenkinsfile vendored
View File

@ -65,7 +65,6 @@ pipeline {
----------------------------------\n"
changeDistroVersion("${version}")
syncSources("${env.BINARY_STORAGE_URL}", "${env.SHARED_BUILD}/downloads")
error("STOPPING because I want it so... :-D")
}
writeFile file: 'VERSION', text: "${env.PACKAGE_NAME}: ${env.BUILD_VERSION}"
}
@ -104,6 +103,13 @@ pipeline {
}
sh "rm -rf ${WORKSPACE}/tmp"
}
post {
always {
script {
syncSources("${env.SHARED_BUILD}/downloads", "${env.BINARY_STORAGE_URL}")
}
}
}
}
} // stages
}
@ -166,25 +172,26 @@ def cleanupDistroVersion() {
}
def syncSources(src, dst) {
def url = (src.contains("http")) ? src : dst
def repoUrl = url.split("//")[1]
String[] repoParts = "${repoUrl}".split("/")
def hasSrcUrl = (src.contains("http"))
def syncCmd = "rsync -avz -e \"ssh\""
def from = src
def to = dst
// convert the URL into ssh syntax:
def url = (hasSrcUrl) ? src : dst
String[] repoParts = url.split("//")[1].split("/")
repoParts[0] = "jenkins@" + repoParts[0] + ":/repo/repo"
sshSrc = repoParts.join("/")
println "sshSrc=${sshSrc}"
def syncCmd = "rsync -avz -e \"ssh\""
// http://nmrepo.netmodule.intranet/src/yocto-downloads/
// synchronizing build job
if(src.contains("http")) {
if(hasSrcUrl) {
println "getting data from server..."
// sh(script: "rsync -avz -e \"ssh\" ${sshSrc} ${dst}")
return
from = sshSrc
}
// synchronizing storage
println "putting data to server..."
else {
println "putting data to server..."
to = sshSrc
}
sh(script: "${syncCmd} ${from}/ ${to}")
}