From c8b22f8cf55ad618b5904fab1868c43b6afa882d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Mattm=C3=BCller?= Date: Mon, 11 Sep 2023 10:26:30 +0200 Subject: [PATCH] jobs/updateSrcRev,common: added artifact with branch to use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the nightly job there might be changes about some source revisions and thus a new branch is created including a pull request. The created branch is written to a file and archived as artifact. This makes it possible to use this branch in a nightly build for building the targets. Signed-off-by: Marc Mattmüller --- jobs/Jenkinsfile_Common | 8 ++++++++ jobs/Jenkinsfile_UpdateSrcRevisions | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/jobs/Jenkinsfile_Common b/jobs/Jenkinsfile_Common index 4279033..ed6eaac 100644 --- a/jobs/Jenkinsfile_Common +++ b/jobs/Jenkinsfile_Common @@ -38,6 +38,14 @@ env.NEXUS_PROTOCOL = "https" env.NEXUS_REPOSITORY = "maven-releases" env.NEXUS_ARTIFACT_COPIER_URL = "${env.NEXUS_PROTOCOL}://${env.NEXUS_URL}/repository/${env.NEXUS_REPOSITORY}" +// General CI definitions +//---------------------------- +env.TARGET_BUILD_JOB = "/nwl-target" +env.SRCREV_UPDATE_JOB = "/nwl-update-src-rev" + +env.NIGHTLY_BRANCH_FILE = "nwl-nightly-branch" + + // Methods declared in external code are accessible // directly from other code in the external file diff --git a/jobs/Jenkinsfile_UpdateSrcRevisions b/jobs/Jenkinsfile_UpdateSrcRevisions index 380601e..00d4535 100644 --- a/jobs/Jenkinsfile_UpdateSrcRevisions +++ b/jobs/Jenkinsfile_UpdateSrcRevisions @@ -41,7 +41,7 @@ pipeline { steps { script { updateTheSourceRevisions(common, "${env.YOCTO_REPO_DIR}", "${params.BUILD_BRANCH}") - commitAndPushTheChanges(common, "${env.YOCTO_REPO_DIR}") + commitAndPushTheChanges(common, "${env.YOCTO_REPO_DIR}", "${params.BUILD_BRANCH}") } } post { @@ -134,9 +134,11 @@ def createPR(theBranch) { } } //--------------------------------------------------------------------------------------------------------------------- -def commitAndPushTheChanges(commonHelpers, repoDir) { +def commitAndPushTheChanges(commonHelpers, repoDir, origBranch) { def commitMsg = "srcrev: updated source revisions by Jenkins Job" def nightlyBranch = "nightly" + def usedBranch = "${origBranch}" + def branchFile = "./${env.NIGHTLY_BRANCH_FILE}" dir(repoDir) { if(sh(returnStdout: true, script: "git status | grep \"modified:\" | wc -l").toInteger() != 0) { @@ -162,7 +164,10 @@ def commitAndPushTheChanges(commonHelpers, repoDir) { """) } createPR("${nightlyBranch}") + usedBranch = "${nightlyBranch}" } - } + } // if changes available } + writeFile(file: branchFile, text: "${usedBranch}") + archiveArtifacts(artifacts: branchFile, onlyIfSuccessful: true) }