diff --git a/Jenkinsfile_sdk b/Jenkinsfile_sdk index 8b5e9b3..789f93e 100644 --- a/Jenkinsfile_sdk +++ b/Jenkinsfile_sdk @@ -25,7 +25,7 @@ pipeline { } options { - timeout(time: 8, unit: 'HOURS') + timeout(time: 5, unit: 'HOURS') buildDiscarder( logRotator(numToKeepStr: '5', daysToKeepStr: '5', @@ -50,7 +50,8 @@ pipeline { yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common" // Prepare Build Environment - env.YOCTO_DEPLOYS = "**/tmp/deploy/sdk" + env.YOCTO_DEPLOYS = "${env.SHARED_BUILD}/tmp/deploy/sdk" + cleanLastBuildArtifacts() yoctocommon.handleSubmodules("${params.RLS_VERSION}") version = yoctocommon.getVersionString("${params.RLS_VERSION}", "sdk") env.BUILD_VERSION = "${version}" @@ -78,31 +79,21 @@ pipeline { 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'" + sh "bash -c '. ./env.image-ostree && bitbake -fc 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) - } + script{ + deploySdkToArtifactory(params.BUILD_FROM_DEV_IMAGE, "${params.MACHINE}") + } + } // success + always { + script { + yoctocommon.syncSources("${env.DOWNLOAD_DIR}", "${env.BINARY_STORAGE_URL}") + } + } // always } } @@ -122,3 +113,39 @@ def printJobParameters() { ----------------------------------\n" } + +def cleanLastBuildArtifacts() { + println "cleaning artifacts from last build..." + sh "rm -f ${env.YOCTO_DEPLOYS}/*" + sh "bash -c '. ./env.image-ostree && bitbake -c cleanall netmodule-linux-sdk'" +} + + +def deploySdkToArtifactory(isBuildFromDev, machine) { + def cpuType = machine.split("-")[0] + def sdkArtifact = sh(returnStdout: true, script: "ls ${env.YOCTO_DEPLOYS}/netmodule-linux-ostree*-netmodule-linux-*.sh").trim() + if(isBuildFromDev) { + def jenkinsBaseUrl = "https://jenkins.netmodule.intranet" + def workspaceUrl = "${jenkinsBaseUrl}/job/NMOS/job/build-sdk/job/${env.BRANCH_NAME}/${currentBuild.number}/execution/node/3/ws/build/tmp/deploy/sdk" + def artifactFile = sh(returnStdout: true, script: "basename ${sdkArtifact}") + println "Download link of image-sdk (cpuType=${cpuType}): ${workspaceUrl}/${artifactFile}" + return + } + + println "Deploying ${sdkArtifact} (cpuType=${cpuType}) to NEXUS..." + nexusArtifactUploader( + nexusVersion: "nexus3", + protocol: "https", + nexusUrl: "repo.netmodule.intranet:443", + groupId: "nm.sdk", + version: "latest", + repository: "nm-os", + credentialsId: "0099cd5a-81d4-4698-9b55-1206895d19fb", + artifacts: [ + [artifactId: "${cpuType}", + classifier: "", + file: "${sdkArtifact}", + type: "sh"] + ] + ); +}