// 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 'lxbuild4' } } parameters { choice(name: 'MACHINE', choices: ['select...', 'am335x-nrhw20', 'am335x-nmhw21', 'imx8-nmhw23', 'am335x-nmhw24', 'am335x-hw25', 'am335x-hw26'], description: 'choose target platform') 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') booleanParam(name: 'BUILD_FROM_DEV_IMAGE', defaultValue: false, description: 'build SDK from dev image') } environment { // SDK Build Parameter (default is recipe netmodule-linux-sdk) IS_NM_LINUX_SDK = "${!params.BUILD_FROM_DEV_IMAGE}" } options { timeout(time: 8, unit: 'HOURS') buildDiscarder( logRotator(numToKeepStr: '5', daysToKeepStr: '5', artifactNumToKeepStr: '5', artifactDaysToKeepStr: '5' ) ) disableConcurrentBuilds() } stages { stage('prepare') { steps { script { if("${params.MACHINE}" == "select...") { currentBuild.result = 'ABORTED' error("Missing machine type --> select parameter MACHINE for a proper build") } // load yocto common file env.ROOTDIR = pwd() yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common" // Prepare Build Environment env.YOCTO_DEPLOYS = "${env.SHARED_BUILD}/tmp/deploy/sdk" yoctocommon.handleSubmodules("${params.RLS_VERSION}") version = yoctocommon.getVersionString("${params.RLS_VERSION}", "sdk") env.BUILD_VERSION = "${version}" currentBuild.displayName = "${version}-${params.MACHINE}-sdk" //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 ("${SHARED_BUILD}/tmp") { deleteDir() } dir ("${SHARED_BUILD}/tmp-glibc") { deleteDir() } } } stage('build') { steps { script { if(env.IS_NM_LINUX_SDK.toBoolean()) { sh "bash -c '. ./env.image-ostree && bitbake netmodule-linux-sdk'" } else { sh "bash -c '. ./env.image-ostree && bitbake -c populate_sdk netmodule-linux-image-dev'" } } archiveArtifacts artifacts: "${env.YOCTO_DEPLOYS}/netmodule-linux-ostree*-netmodule-linux-*.sh", onlyIfSuccessful: true } post { always { script { yoctocommon.syncSources("${env.DOWNLOAD_DIR}", "${env.BINARY_STORAGE_URL}") } } } } stage('collect versions') { steps { script { revisions = yoctocommon.getAutoRevHashes('ostree') 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\ CLEAN_BUILD = ${params.CLEAN_BUILD}\n\ IS_NM_LINUX_SDK = ${env.IS_NM_LINUX_SDK}\n\ RLS_VERSION = ${params.RLS_VERSION}\n\ --> version = ${env.BUILD_VERSION}\n\ ----------------------------------\n" }