From 66bb57956ffc73e60cbd33aa88d63c876d6ef7e5 Mon Sep 17 00:00:00 2001
From: Tim Jaacks <tim.jaacks@seco.com>
Date: Fri, 21 Jul 2023 16:46:21 +0200
Subject: [PATCH] Yocto build: use common artifact pathspec for image and SDK
 builds

This is the first step on the way to a common pipeline for all build
configurations.
---
 build-common.yml | 25 ++++++++-----------------
 build-yocto.yml  |  2 --
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/build-common.yml b/build-common.yml
index 25bc4d63..e0a0948b 100644
--- a/build-common.yml
+++ b/build-common.yml
@@ -98,29 +98,20 @@ workflow:
     expire_in: 1 week
     reports:
       dotenv: build.env
-
-.build_image:
-  artifacts:
-    paths: &build_image_artifacts_paths
+    paths: &artifacts_paths
+      # List of all potential artifact paths. Not all of them are present in each build
+      # configuration, e.g. the SDK path exists in SDK builds only. We still specify all
+      # of them here in order to have a generic build class for all builds. Pathsspecs
+      # which do not exist in a specific configuration are simply ignored by GitLab.
       - build-*/tmp/deploy/images/**/*
       - build-*/tmp/deploy/licenses/**/license.manifest
-      - build.env
-  cache:
-    # Cache the build artifacts for subsequent stages in the same pipeline
-    - key: ${CI_PIPELINE_ID}-${CI_JOB_NAME}
-      policy: push
-      paths: *build_image_artifacts_paths
-
-.build_sdk:
-  artifacts:
-    paths: &build_sdk_artifacts_paths
       - build-*/tmp/deploy/sdk/*
       - build.env
   cache:
     # Cache the build artifacts for subsequent stages in the same pipeline
     - key: ${CI_PIPELINE_ID}-${CI_JOB_NAME}
       policy: push
-      paths: *build_sdk_artifacts_paths
+      paths: *artifacts_paths
 
 # --------------------------------------------------------------------------------------
 # Stage: test
@@ -218,7 +209,7 @@ workflow:
         --release-suffix="${RELEASE_SUFFIX}"
   cache:
     - <<: *pull_build_cache
-      paths: *build_image_artifacts_paths
+      paths: *artifacts_paths
     - *push_package_cache
 
 .package_sdk:
@@ -232,7 +223,7 @@ workflow:
         --release-suffix="${RELEASE_SUFFIX}"
   cache:
     - <<: *pull_build_cache
-      paths: *build_sdk_artifacts_paths
+      paths: *artifacts_paths
     - *push_package_cache
 
 # --------------------------------------------------------------------------------------
diff --git a/build-yocto.yml b/build-yocto.yml
index 7573ffaa..adb090f2 100644
--- a/build-yocto.yml
+++ b/build-yocto.yml
@@ -92,7 +92,6 @@
 .build_yocto_image:
   extends:
     - .build_yocto
-    - .build_image
   variables:
     BITBAKE_TASK: "build"
   script:
@@ -104,7 +103,6 @@
 .build_yocto_sdk:
   extends:
     - .build_yocto
-    - .build_sdk
   variables:
     BITBAKE_TASK: "populate_sdk"
   rules:
-- 
GitLab