diff --git a/jobs/Jenkinsfile_Build b/jobs/Jenkinsfile_Build index 109d432..393f7f6 100644 --- a/jobs/Jenkinsfile_Build +++ b/jobs/Jenkinsfile_Build @@ -11,11 +11,18 @@ def targetList // of a certain label (like core-os_buildagent) to have define credentials to get // the files. In the current case we use any agent. node() { - // get the list of the targets: - targetList = sh(returnStdout: true, script: "cat ./jobs/nwlTargets").trim() + dir("tmp-repo") { + // clone the repository to get the file with the target list + sshagent (credentials: ['admin_credentials']) { + sh "git clone --depth 1 --branch ${env.BRANCH_NAME} ssh://git@bitbucket.gad.local:7999/nm-nsp/nwl-ci.git ." + } - // load common file - common = load "./jobs/Jenkinsfile_Common" + // get the list of the targets: + targetList = sh(returnStdout: true, script: "cat ./jobs/nwlTargets").trim() + + // load common file + common = load "./jobs/Jenkinsfile_Common" + } } // declarative pipeline diff --git a/jobs/Jenkinsfile_Common b/jobs/Jenkinsfile_Common index ca94c81..a9ad517 100644 --- a/jobs/Jenkinsfile_Common +++ b/jobs/Jenkinsfile_Common @@ -40,6 +40,11 @@ def cleaningClonedRepoDir() { sh("git clean -ffdx") } +//----------------------------------------------------------------------------- +def getGitCredentialID() { + return 'admin_credentials' +} + //----------------------------------------------------------------------------- def setupGlobalEnvironmentVariables(repoDir, machine) { @@ -73,15 +78,16 @@ def removePreExistingYoctoConfigs(confPath) { //----------------------------------------------------------------------------- def gitCheckout(gitUrl, branchTag, repoDir, hasSubmodules) { println "checking out ${gitUrl} to ${repoDir}..." + def gitCredentials = getGitCredentialID() if(!fileExists("./${repoDir}")) { - sshagent (credentials: [env.SSH_ID]) { + sshagent (credentials: [gitCredentials]) { def inclSubmodulesOpt = hasSubmodules ? "--recurse-submodules" : "" sh(script: "git clone ${inclSubmodulesOpt} ${gitUrl} ${repoDir}") } } dir("${repoDir}") { def updateSubmodulesCmd = hasSubmodules ? " && git submodule update --init --recursive" : "" - sshagent (credentials: [env.SSH_ID]) { + sshagent (credentials: [gitCredentials]) { sh(script: "git fetch -ap && git fetch -t") sh(script: "git checkout ${branchTag} && git pull --rebase ${updateSubmodulesCmd}") } @@ -232,7 +238,8 @@ def buildTheYoctoPackage() { def buildCall = "bitbake ${env.BITBAKE_CMD} >> ${env.SHARED_BUILD}/${yoctoOutFile} 2>&1" def buildCmd = "${sourceCall}; ${buildCall}" def bitbakeStatus = 0; - sshagent (credentials: [env.SSH_ID]) { + def gitCredentials = getGitCredentialID() + sshagent (credentials: [gitCredentials]) { bitbakeStatus = sh(returnStatus: true, script: "bash -c '${buildCmd}'") } println "bitbakeStatus=${bitbakeStatus}"