jenkins: refactored submodule handling and set distro version on release
Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
parent
cd7ce24604
commit
305353813b
|
|
@ -40,15 +40,7 @@ pipeline {
|
|||
stage('prepare') {
|
||||
steps {
|
||||
script {
|
||||
if(isReleaseRequested("${params.RLS_VERSION}")) {
|
||||
sh 'git submodule update' // set all submodules to freezed commit
|
||||
}
|
||||
else {
|
||||
sh 'git submodule update --remote --rebase' // update all submodules to HEAD
|
||||
}
|
||||
submoduleStatus = sh(returnStdout: true, script: "git submodule status").trim() // print submodule hashes to jenkins log
|
||||
println "${submoduleStatus}"
|
||||
|
||||
handle_submodules("${params.RLS_VERSION}")
|
||||
version = build_version("${params.RLS_VERSION}")
|
||||
|
||||
println "----------------------------------\n Job Parameters:\n----------------------------------\n\
|
||||
|
|
@ -58,9 +50,13 @@ pipeline {
|
|||
RLS_VERSION = ${params.RLS_VERSION}\n\
|
||||
--> version = ${version}\n\
|
||||
----------------------------------\n"
|
||||
|
||||
env.BUILD_VERSION = "${version}"
|
||||
currentBuild.displayName = "${version}-${MACHINE}-${IMAGE_TYPE}" //replace Bitbake timestamp after building
|
||||
|
||||
if(isRelease("${params.RLS_VERSION}")) {
|
||||
change_distro_version("${version}")
|
||||
}
|
||||
|
||||
}
|
||||
writeFile file: 'VERSION', text: "${PACKAGE_NAME}: ${BUILD_VERSION}"
|
||||
}
|
||||
|
|
@ -89,16 +85,27 @@ pipeline {
|
|||
}
|
||||
|
||||
|
||||
def isReleaseRequested(versionParam) {
|
||||
def isRelease(versionParam) {
|
||||
if((versionParam == "") || (versionParam == "latest")) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
def handle_submodules(versionParam) {
|
||||
if(isRelease(versionParam)) {
|
||||
sh 'git submodule update' // set all submodules to freezed commit
|
||||
}
|
||||
else {
|
||||
sh 'git submodule update --remote --rebase' // update all submodules to HEAD
|
||||
}
|
||||
submoduleStatus = sh(returnStdout: true, script: "git submodule status").trim() // print submodule hashes to jenkins log
|
||||
println "${submoduleStatus}"
|
||||
}
|
||||
|
||||
def build_version(versionParam) {
|
||||
def gitCmd = "git describe --tags"
|
||||
if(!isReleaseRequested(versionParam)) {
|
||||
if(!isRelease(versionParam)) {
|
||||
gitCmd = "${gitCmd} --dirty"
|
||||
}
|
||||
gitversion = sh(returnStdout: true, script: "${gitCmd}").trim()
|
||||
|
|
@ -111,6 +118,13 @@ def build_version(versionParam) {
|
|||
return rlsVersion
|
||||
}
|
||||
|
||||
def change_distro_version(versionString){
|
||||
println "Set the distro version to ${versionString}..."
|
||||
def versionTag = "DISTRO_VERSION = "
|
||||
def sedCmd = "sed -i 's/^${versionTag}.*\$/${versionTag}\"${versionString}\"/'"
|
||||
sh(script:"${sedCmd} meta-netmodule-distro/conf/distro/netmodule-linux.conf")
|
||||
}
|
||||
|
||||
|
||||
def build_and_archive() {
|
||||
if (params.IMAGE_TYPE == 'sdk') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue