0

I have this scenario where I want to run the trigger in build stage only when $FLAG variable has been set by the .pre stage. However, the build stage never runs.

How should I conditionally trigger a downstream pipeline?

checkArtifactPresent:
  stage: .pre
  script:
    - >
      set +e;
      if curl -s -S -f $NEXUS_RAW_PICKER_REPOSITORY/${PRODUCT_FLAVOR}/${PRODUCT_FLAVOR}-${BUILD_TYPE}v${PICKER_TEMPLATE_TAG}.apk --output ${PRODUCT_FLAVOR}-${BUILD_TYPE}v${PICKER_TEMPLATE_TAG}.apk;
      then
        export FLAG= true;
      fi

buildArtifact:
  stage: build
  only:
   variables:
     - $FLAG
  trigger:
   project: dev/project_name
   strategy: depend

1 Answer 1

1

You could use dynamic child pipelines. (https://docs.gitlab.com/ee/ci/parent_child_pipelines.html#dynamic-child-pipelines).

You could create a job for triggering your job "buildArtifact" in a yml-file created with jsonnet in your "checkArtifactPresent". With using "--ext-str" or "--ext-code" in jsonnet. You can control the yml-file creation (https://jsonnet.org/learning/tutorial.html#parameterize-entire-config).

Read more https://jsonnet.org/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.