From b30990d1a81b83291c14a1721b5f37eef4cee0a9 Mon Sep 17 00:00:00 2001
From: Chase Qi <chase.qi@linaro.org>
Date: Thu, 23 Jun 2022 16:42:09 +0800
Subject: [PATCH] .oniro-ci: attach callback url to squad build ID instead of
 pipeline ID

Pipeline ID is used as squad project level build ID. However, squad
build ID is the one to use for api calls. It is unique cross the
instance.

Signed-off-by: Chase Qi <chase.qi@linaro.org>
---
 .oniro-ci/test-generic.yaml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.oniro-ci/test-generic.yaml b/.oniro-ci/test-generic.yaml
index 82832c7f..af9b6a10 100644
--- a/.oniro-ci/test-generic.yaml
+++ b/.oniro-ci/test-generic.yaml
@@ -75,7 +75,8 @@
         curl $CI_SQUAD_INSTANCE/api/submitjob/oniro-core/$CI_PROJECT_NAME/$CI_PIPELINE_ID/$MACHINE --header "Auth-Token: $CI_SQUAD_TOKEN"  --form "backend=oniro_lava" --form "definition=@${job_def}"
       done
       # Attach a callback to this build to trigger the lava-report job
-      curl -X POST $CI_SQUAD_INSTANCE/api/build/$CI_PIPELINE_ID/callbacks/ -F "callback_url=$CALLBACK_URL"
+      squad_build_id="$(curl --silent "$CI_SQUAD_INSTANCE/api/builds/?version=$CI_PIPELINE_ID" | jq -r '.results[0].id')"
+      curl -X POST $CI_SQUAD_INSTANCE/api/builds/$squad_build_id/callbacks/ --header "Authorization: Token $CI_SQUAD_TOKEN" -F "callback_url=$CALLBACK_URL"
   artifacts:
     paths:
       - lava_jobs/*.yaml
-- 
GitLab