From 7bd78810f007a34d91591c5cc66008aa89c52fd1 Mon Sep 17 00:00:00 2001
From: Andrii Sosiuk <andrii.sosiuk@seco.com>
Date: Fri, 19 Jul 2024 17:05:10 +0200
Subject: [PATCH] PBB-32 Fix suffix addition in FNGo pipeline for custom
 projects  due to an issue in GitLab where escaped variables are not correctly
  passed to child pipelines, a workaround is required.  As a result, we use
 raw variables.  The DEFERRED_RELEASE_VERSION variable was introduced for this
 purpose.  However, for custom builds, we have an additional place where we
 modify  the DEFERRED_RELEASE_VERSION variable to add a suffix.  Therefore,
 extra interim variables need to be added to handle the workaround  and ensure
 we get the raw variable in the end.

---
 build-pipeline.yml          |  2 ++
 manifest-pipeline-yocto.yml | 11 ++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/build-pipeline.yml b/build-pipeline.yml
index 145cdc3f..ffc9f0b8 100644
--- a/build-pipeline.yml
+++ b/build-pipeline.yml
@@ -220,6 +220,8 @@ workflow:
     RELEASE_NAME_EXPRESSION: Yocto-$${RELEASE_VERSION}
   script:
     - *source_bitbake_env
+    - echo ${DISTRO_VERSION}
+    - echo ${DEFERRED_RELEASE_VERSION}
     - echo ${RELEASE_VERSION_EXPRESSION}
     - echo ${RELEASE_NAME_EXPRESSION}
     - RELEASE_VERSION=$(eval echo "${RELEASE_VERSION_EXPRESSION}")
diff --git a/manifest-pipeline-yocto.yml b/manifest-pipeline-yocto.yml
index 9ef8d69c..976261a3 100644
--- a/manifest-pipeline-yocto.yml
+++ b/manifest-pipeline-yocto.yml
@@ -103,10 +103,11 @@ fngsystem-pipeline:
     # https://gitlab.com/gitlab-org/gitlab/-/issues/273409
     # Escaped variables are not correctly passed to child pipelines. Proposed workaround
     # is to use raw variables, but we need at least GitLab 15.6 for that. As soon as we
-    # update our GitLab, we can get rid of the DEFERRED_RELEASE_VERSION variable and
-    # assign its value to RELEASE_VERSION_EXPRESSION directly.
-    DEFERRED_RELEASE_VERSION: $$(echo $$DISTRO_VERSION | sed "s/fngsystem-//")
-    RELEASE_VERSION_EXPRESSION: $DEFERRED_RELEASE_VERSION
-    RELEASE_NAME_EXPRESSION: FNGSystem-${DEFERRED_RELEASE_VERSION}
+    # update our GitLab, we can get rid of the DEFERRED_RELEASE_VERSION,
+    # interim variables and assign its value to RELEASE_VERSION_EXPRESSION directly.
+    PREINTERIM_DR_VERSION: $DEFERRED_RELEASE_VERSION
+    INTERIM_DR_VERSION: $$(echo $PREINTERIM_DR_VERSION | sed "s/fngsystem-//")
+    RELEASE_VERSION_EXPRESSION: $INTERIM_DR_VERSION
+    RELEASE_NAME_EXPRESSION: FNGSystem-${INTERIM_DR_VERSION}
     ARTIFACTS_PATH: build-*/tmp/deploy/images/**/*
     PACKAGE_TYPE: image
-- 
GitLab