From 2d50a481721e7884847bc7703007d5eae4ef9533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= <dennis.glaeser@iws.uni-stuttgart.de> Date: Fri, 28 May 2021 16:41:06 +0200 Subject: [PATCH] [ci] pass variable in api trigger --- .gitlab-ci.yml | 2 ++ .gitlab-ci/default.yml | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 469bb01f7a..bfdd953865 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,6 +40,7 @@ check-pipeline-status: echo "No successful pipeline found. Triggering new pipeline..." curl --request POST --form "token=$CI_JOB_TOKEN" \ --form ref=$CI_COMMIT_BRANCH \ + --form "variables[CI_TEST_AGAINST_LAST_SUCCESSFUL]=true" \ "https://git.iws.uni-stuttgart.de/api/v4/projects/31/trigger/pipeline" else echo "Found successful pipeline for the current state of the branch. Not testing again." @@ -63,6 +64,7 @@ check-pipeline-status: TRIGGER_SOURCE: $CI_PIPELINE_SOURCE COMMIT_BRANCH: $CI_COMMIT_BRANCH MR_TARGET_BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + TEST_AGAINST_LAST_SUCCESSFUL: $CI_TEST_AGAINST_LAST_SUCCESSFUL rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: always diff --git a/.gitlab-ci/default.yml b/.gitlab-ci/default.yml index dead4f5db9..3783d27951 100644 --- a/.gitlab-ci/default.yml +++ b/.gitlab-ci/default.yml @@ -34,9 +34,8 @@ select tests: echo "Skipping test selection, build/test stages will consider all tests!" touch affectedtests.json - elif [[ "$TRIGGER_SOURCE" == "pipeline" ]]; then - echo "Starting pipeline triggered from another pipeline" - echo "Determining sha with the last successful pipeline to test against" + elif [ -n $TEST_AGAINST_LAST_SUCCESSFUL ]; then + echo "Determining sha of the last successful pipeline to test against" curl --header --form "token=$CI_JOB_TOKEN" \ "https://git.iws.uni-stuttgart.de/api/v4/projects/31/pipelines/?status=success" \ > pipeline_status.json -- GitLab