jenkins: used credential ID of the belonging server

Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmueller 2021-10-27 15:58:42 +02:00
parent 526eb8729b
commit 01e8be71b0
5 changed files with 55 additions and 13 deletions

View File

@ -40,7 +40,7 @@ def isRelease(versionParam) {
def handleSubmodules(versionParam) { def handleSubmodules(versionParam) {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
println "init submodules..." println "init submodules..."
sh 'git submodule update --init' sh 'git submodule update --init'
if(isRelease(versionParam)) { if(isRelease(versionParam)) {
@ -113,7 +113,7 @@ def buildVersionString(imageType, actualBaseVersionString, versionParameter) {
} }
def getVersionString(versionParam, imageType) { def getVersionString(versionParam, imageType) {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
sh 'git fetch -ap' sh 'git fetch -ap'
sh 'git fetch -t' sh 'git fetch -t'
} }

View File

@ -16,7 +16,7 @@ pipeline {
choice(name: 'MACHINE', choices: ['select...', 'am335x-nrhw20', 'am335x-nmhw21', 'imx8-nmhw23', 'am335x-nmhw24', 'am335x-hw25', 'am335x-hw26'], description: 'choose target platform') 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') 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') string(name: 'RLS_VERSION', defaultValue: '', description: 'Set the version to build and use committed submodules')
string(name: 'NODE_NAME', defaultValue: 'oem-ci', description: 'Overwrite default node name to build on') string(name: 'NODE_NAME', defaultValue: 'lxbuild3', description: 'Overwrite default node name to build on')
booleanParam(name: 'CLEAN_BUILD', defaultValue: false, description: 'clean all temp directories before build starts') booleanParam(name: 'CLEAN_BUILD', defaultValue: false, description: 'clean all temp directories before build starts')
} }
@ -49,6 +49,19 @@ pipeline {
// correct build directory // correct build directory
env.BUILD_DIR_POSTFIX = "${params.IMAGE_TYPE}" == "lava" ? "-fct" : "-${params.IMAGE_TYPE}" env.BUILD_DIR_POSTFIX = "${params.IMAGE_TYPE}" == "lava" ? "-fct" : "-${params.IMAGE_TYPE}"
// take the correct user ID for the ssh connection of
// the belonging build server
if("${params.NODE_NAME}" == "lxbuild4") {
env.SSH_ID = '6b90ac7f-9596-4e43-923b-6c9179a10d8a'
}
else if("${params.NODE_NAME}" == "lxbuild3") {
env.SSH_ID = '70c27394-cb7d-4304-aed1-89e15a3a78d0'
}
else {
env.SSH_ID = ''
}
println "SSH_ID used: ${env.SSH_ID}"
// load yocto common file // load yocto common file
env.ROOTDIR = pwd() env.ROOTDIR = pwd()
yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common" yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common"
@ -130,7 +143,7 @@ def printJobParameters() {
def build(envType, imgType) { def build(envType, imgType) {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
def envPostFix = "${envType}" == "" ? "" : "-${envType}" def envPostFix = "${envType}" == "" ? "" : "-${envType}"
sh "bash -c '. ./env.image${envPostFix} > /dev/null && bitbake -q -k virtual/netmodule-image'" sh "bash -c '. ./env.image${envPostFix} > /dev/null && bitbake -q -k virtual/netmodule-image'"
} }

View File

@ -16,7 +16,7 @@ pipeline {
choice(name: 'MACHINE', choices: ['select...', 'am335x-nrhw20', 'am335x-nmhw21', 'imx8-nmhw23', 'am335x-nmhw24', 'am335x-hw25', 'am335x-hw26'], description: 'choose target platform') 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: ['dev', 'bootloader', 'release'], description: 'choose image type') choice(name: 'IMAGE_TYPE', choices: ['dev', 'bootloader', 'release'], description: 'choose image type')
string(name: 'RLS_VERSION', defaultValue: '', description: 'Set the version to build and use committed submodules') string(name: 'RLS_VERSION', defaultValue: '', description: 'Set the version to build and use committed submodules')
string(name: 'NODE_NAME', defaultValue: 'oem-ci', description: 'Overwrite default node name to build on') string(name: 'NODE_NAME', defaultValue: 'lxbuild4', description: 'Overwrite default node name to build on')
booleanParam(name: 'CLEAN_BUILD', defaultValue: false, description: 'clean all temp directories before build starts') booleanParam(name: 'CLEAN_BUILD', defaultValue: false, description: 'clean all temp directories before build starts')
} }
@ -52,6 +52,19 @@ pipeline {
// correct build directory // correct build directory
env.BUILD_DIR_POSTFIX = "" env.BUILD_DIR_POSTFIX = ""
// take the correct user ID for the ssh connection of
// the belonging build server
if("${params.NODE_NAME}" == "lxbuild4") {
env.SSH_ID = '6b90ac7f-9596-4e43-923b-6c9179a10d8a'
}
else if("${params.NODE_NAME}" == "lxbuild3") {
env.SSH_ID = '70c27394-cb7d-4304-aed1-89e15a3a78d0'
}
else {
env.SSH_ID = ''
}
println "SSH_ID used: ${env.SSH_ID}"
// load yocto common file // load yocto common file
env.ROOTDIR = pwd() env.ROOTDIR = pwd()
yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common" yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common"
@ -152,7 +165,7 @@ def cleanLeftOvers(cleaningDir) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
def build(imgType) { def build(imgType) {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
def tgtImgType = "${imgType}" == "bootloader" ? "dev" : "${imgType}" def tgtImgType = "${imgType}" == "bootloader" ? "dev" : "${imgType}"
def imgTypePostfix = "${tgtImgType}" == "" ? "" : "-${tgtImgType}" def imgTypePostfix = "${tgtImgType}" == "" ? "" : "-${tgtImgType}"
sh "bash -c '. ./env.image-ostree > /dev/null && bitbake -q -k netmodule-linux-image${imgTypePostfix}'" sh "bash -c '. ./env.image-ostree > /dev/null && bitbake -q -k netmodule-linux-image${imgTypePostfix}'"

View File

@ -45,6 +45,19 @@ pipeline {
// correct build directory // correct build directory
env.BUILD_DIR_POSTFIX = "" env.BUILD_DIR_POSTFIX = ""
// take the correct user ID for the ssh connection of
// the belonging build server
if("${params.NODE_NAME}" == "lxbuild4") {
env.SSH_ID = '6b90ac7f-9596-4e43-923b-6c9179a10d8a'
}
else if("${params.NODE_NAME}" == "lxbuild3") {
env.SSH_ID = '70c27394-cb7d-4304-aed1-89e15a3a78d0'
}
else {
error("Declare the NODE_NAME specific to the build agent")
}
println "SSH_ID used: ${env.SSH_ID}"
// load yocto common file // load yocto common file
env.ROOTDIR = pwd() env.ROOTDIR = pwd()
yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common" yoctocommon = load "${env.ROOTDIR}/Jenkinsfile_Common"
@ -79,7 +92,7 @@ pipeline {
stage('build') { stage('build') {
steps { steps {
script { script {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
if(env.IS_NM_LINUX_SDK.toBoolean()) { if(env.IS_NM_LINUX_SDK.toBoolean()) {
sh "bash -c '. ./env.image-ostree && bitbake -q netmodule-linux-sdk'" sh "bash -c '. ./env.image-ostree && bitbake -q netmodule-linux-sdk'"
} }
@ -124,7 +137,7 @@ def printJobParameters() {
def cleanLastBuildArtifacts() { def cleanLastBuildArtifacts() {
println "cleaning artifacts from last build..." println "cleaning artifacts from last build..."
sh "rm -f ${env.YOCTO_DEPLOYS}/*" sh "rm -f ${env.YOCTO_DEPLOYS}/*"
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
sh "bash -c '. ./env.image-ostree > /dev/null && git fetch -ap && bitbake -q -c cleanall netmodule-linux-sdk'" sh "bash -c '. ./env.image-ostree > /dev/null && git fetch -ap && bitbake -q -c cleanall netmodule-linux-sdk'"
} }
} }

View File

@ -2,7 +2,7 @@
pipeline { pipeline {
agent { agent {
node { node {
label 'oem-linux' label 'lxbuild4'
} }
} }
@ -14,6 +14,7 @@ pipeline {
environment { environment {
SUBMODULE_VERSION_FILE = "submodule_revisions" SUBMODULE_VERSION_FILE = "submodule_revisions"
SOURCE_REVISION_UPDATE_LOG = "src_rev_update.log" SOURCE_REVISION_UPDATE_LOG = "src_rev_update.log"
SSH_ID = '6b90ac7f-9596-4e43-923b-6c9179a10d8a'
} }
options { options {
@ -66,6 +67,8 @@ pipeline {
def printJobParameters() { def printJobParameters() {
def node_name = "${NODE_NAME}"
println "Running on agent: ${node_name}\n\n"
println "----------------------------------\n\ println "----------------------------------\n\
Job Parameters:\n\ Job Parameters:\n\
----------------------------------\n\ ----------------------------------\n\
@ -75,7 +78,7 @@ def printJobParameters() {
} }
def prepareUpdate() { def prepareUpdate() {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
sh 'git submodule update --init' // init submodules used if first checkout sh 'git submodule update --init' // init submodules used if first checkout
} }
def userId = "${currentBuild.getBuildCauses()[0].userId}" def userId = "${currentBuild.getBuildCauses()[0].userId}"
@ -94,7 +97,7 @@ def prepareUpdate() {
} }
def updateSubmodules(isNmUpdate, isCommunityUpdate) { def updateSubmodules(isNmUpdate, isCommunityUpdate) {
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
if(isNmUpdate) { if(isNmUpdate) {
sh(script: "git submodule update --remote --rebase meta-netmodule-*") sh(script: "git submodule update --remote --rebase meta-netmodule-*")
} }
@ -131,7 +134,7 @@ def updateSourceRevisions(isNmUpdate) {
def commitSourceRevisionChanges() { def commitSourceRevisionChanges() {
println "commit source revision changes..." println "commit source revision changes..."
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
sh(returnStdout: true, script: "./src-rev-commit.sh -b develop -v -l ./srcrev-commit.log") sh(returnStdout: true, script: "./src-rev-commit.sh -b develop -v -l ./srcrev-commit.log")
} }
sh "cat ./srcrev-commit.log >> ./${env.SOURCE_REVISION_UPDATE_LOG}" sh "cat ./srcrev-commit.log >> ./${env.SOURCE_REVISION_UPDATE_LOG}"
@ -152,7 +155,7 @@ def commitChanges(isNmUpdate, isCommunityUpdate) {
println "everything up to date, nothing to commit" println "everything up to date, nothing to commit"
return return
} }
sshagent (credentials: ['7767e711-08a4-4c71-b080-197253dd7392']) { sshagent (credentials: [env.SSH_ID]) {
sh(script: "git commit -m \"submodules: updated ${updatedLayers} hashes, triggered by ${env.TRIGGERED_USER}\" && git push") sh(script: "git commit -m \"submodules: updated ${updatedLayers} hashes, triggered by ${env.TRIGGERED_USER}\" && git push")
} }
} }