151 lines
5.2 KiB
Plaintext
151 lines
5.2 KiB
Plaintext
// Loading code requires a NODE context
|
|
// But we want the code accessible outside the node Context
|
|
// So declare yoctocommon (object created by the LOAD operation) outside the Node block.
|
|
def yoctocommon
|
|
|
|
|
|
// declarative pipeline
|
|
pipeline {
|
|
agent {
|
|
node {
|
|
label 'oem-ci'
|
|
}
|
|
}
|
|
|
|
parameters {
|
|
choice(name: 'MACHINE', choices: ['select...', 'am335x-nrhw20', 'am335x-nmhw21', 'imx8-nmhw23', 'am335x-nmhw24', 'am335x-hw25', 'am335x-hw26'], description: 'choose target platform')
|
|
choice(name: 'IMAGE_TYPE', choices: ['lava', 'fct', 'minimal'], description: 'choose image type')
|
|
string(name: 'RLS_VERSION', defaultValue: '', description: 'Set the version to build and use committed submodules')
|
|
booleanParam(name: 'CLEAN_BUILD', defaultValue: false, description: 'clean all temp directories before build starts')
|
|
}
|
|
|
|
environment {
|
|
IMG_OUTPUT_DIR = "tmp/build-output"
|
|
}
|
|
|
|
options {
|
|
timeout(time: 5, unit: 'HOURS')
|
|
buildDiscarder(
|
|
logRotator(numToKeepStr: '50',
|
|
daysToKeepStr: '3',
|
|
artifactNumToKeepStr: '50',
|
|
artifactDaysToKeepStr: '3'
|
|
)
|
|
)
|
|
disableConcurrentBuilds()
|
|
}
|
|
|
|
stages {
|
|
stage('prepare') {
|
|
steps {
|
|
script {
|
|
if("${params.MACHINE}" == "select...") {
|
|
currentBuild.result = 'ABORTED'
|
|
error("Missing machine type --> select parameter MACHINE for a proper build")
|
|
}
|
|
|
|
// this definition is needed for selecting the
|
|
// correct build directory
|
|
env.BUILD_DIR_POSTFIX = "${params.IMAGE_TYPE}" == "lava" ? "-fct" : "-${params.IMAGE_TYPE}"
|
|
|
|
// load yocto common file
|
|
env.ROOTDIR = pwd()
|
|
yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common"
|
|
|
|
// Prepare Build Environment
|
|
env.YOCTO_DEPLOYS = "${env.BUILD_DEPLOY_DIR}/${params.MACHINE}"
|
|
yoctocommon.handleSubmodules("${params.RLS_VERSION}")
|
|
version = yoctocommon.getVersionString("${params.RLS_VERSION}", "${params.IMAGE_TYPE}")
|
|
env.BUILD_VERSION = "${version}"
|
|
currentBuild.displayName = "${version}-${params.MACHINE}-${params.IMAGE_TYPE}" //replace Bitbake timestamp after building
|
|
printJobParameters()
|
|
yoctocommon.changeDistroVersion("${version}")
|
|
yoctocommon.syncSources("${env.BINARY_STORAGE_URL}", "${env.DOWNLOAD_DIR}")
|
|
}
|
|
writeFile file: 'VERSION', text: "${env.PACKAGE_NAME}: ${env.BUILD_VERSION}"
|
|
}
|
|
}
|
|
|
|
stage('clean') {
|
|
when { expression { return params.CLEAN_BUILD } }
|
|
steps {
|
|
dir ("${env.SHARED_BUILD}/tmp") { deleteDir() }
|
|
dir ("${env.SHARED_BUILD}/tmp-glibc") { deleteDir() }
|
|
}
|
|
}
|
|
|
|
stage('build') {
|
|
steps {
|
|
script {
|
|
build(params.IMAGE_TYPE, params.IMAGE_TYPE)
|
|
createArchive(params.IMAGE_TYPE, env.IMG_OUTPUT_DIR)
|
|
yoctocommon.archiveImages(env.IMG_OUTPUT_DIR, params.IMAGE_TYPE)
|
|
sh "rm -rf ${IMG_OUTPUT_DIR}"
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
script {
|
|
yoctocommon.syncSources("${env.DOWNLOAD_DIR}", "${env.BINARY_STORAGE_URL}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('collect versions') {
|
|
steps {
|
|
script {
|
|
revisions = yoctocommon.getAutoRevHashes(params.IMAGE_TYPE)
|
|
writeFile(file: "${env.AUTOREV_VERSION_FILE}", text: "${revisions}")
|
|
}
|
|
}
|
|
post {
|
|
success {
|
|
archiveArtifacts(artifacts: "${env.SUBMODULE_VERION_FILE}, ${env.AUTOREV_VERSION_FILE}, ${env.DISTRO_VERSION_FILE}", onlyIfSuccessful: false)
|
|
}
|
|
}
|
|
}
|
|
|
|
} // stages
|
|
}
|
|
|
|
|
|
def printJobParameters() {
|
|
println "----------------------------------\n\
|
|
Job Parameters:\n\
|
|
----------------------------------\n\
|
|
MACHINE = ${params.MACHINE}\n\
|
|
IMAGE_TYPE = ${params.IMAGE_TYPE}\n\
|
|
CLEAN_BUILD = ${params.CLEAN_BUILD}\n\
|
|
RLS_VERSION = ${params.RLS_VERSION}\n\
|
|
--> version = ${env.BUILD_VERSION}\n\
|
|
----------------------------------\n"
|
|
}
|
|
|
|
|
|
def build(envType, imgType) {
|
|
def envPostFix = "${envType}" == "" ? "" : "-${envType}"
|
|
sh "bash -c '. ./env.image${envPostFix} && bitbake -k virtual/netmodule-image'"
|
|
}
|
|
|
|
|
|
def createArchive(imgType, outputDir) {
|
|
def imgTypePostfix = "${imgType}" == "" ? "" : "-${imgType}"
|
|
dir (outputDir) {
|
|
def image_basename = "netmodule-linux-image${imgTypePostfix}-${params.MACHINE}"
|
|
def basename_built = "${env.YOCTO_DEPLOYS}/${image_basename}"
|
|
def basename_archive = "./image${imgTypePostfix}-${params.MACHINE}"
|
|
|
|
sh "cp ${basename_built}.manifest ${basename_archive}.manifest"
|
|
sh "bash -c '${WORKSPACE}/openembedded-core/scripts/buildhistory-collect-srcrevs -p ${env.BUILD_HISTORY_DIR} > srcrev-${params.MACHINE}${imgTypePostfix}.inc'"
|
|
|
|
sh label: 'Copy License Manifest', returnStatus: true, script: """
|
|
LATEST_LICENSE_DIR=\$(ls -Artd ${env.BUILD_LICENSE_DIR}/netmodule-linux-image${imgTypePostfix}* | tail -n 1)
|
|
cp \$LATEST_LICENSE_DIR/license.manifest ${basename_archive}_license.manifest
|
|
"""
|
|
|
|
sh "cp ${env.YOCTO_DEPLOYS}/fitImage-${image_basename}-${params.MACHINE} fitImage-${image_basename}"
|
|
sh "cp ${basename_built}.cpio.gz ${basename_archive}.cpio.gz"
|
|
}
|
|
}
|