-1

I have a CI that runs when a tag is created, but I would like to be able to run it manually as well. Unfortunately, the CI uses the tag name to set the name of the artifact.

I tried this:

stages:
  - build

workflow:
  rules:
    - if: $CI_COMMIT_TAG
    - if: $CI_JOB_MANUAL
      variables:
        - CI_COMMIT_TAG: "manual"

build_app:
  script:
    - echo "Build completed"
  artifacts:
    expire_in: 30 days
    paths:
      - .
    name: "app-$CI_COMMIT_TAG"

What I would like is:

  • With git tag v2.4.1 && git push --tags, it should create the artifact app-v2.4.1.zip.
  • With "Pipeline --> Run pipeline", it should create the artifcat app-manual.zip.

Unfortunately, I can't run it manually (Pipelines --> Run Pipeline) because "Pipeline filtered out by workflow rules."

How to fix my CI?

0

1 Answer 1

0

Instead of $CI_JOB_MANUAL, you have to use $CI_PIPELINE_SOURCE and compare it to "web". Here is the complete file:

stages:
  - build

workflow:
  rules:
    - if: $CI_COMMIT_TAG
    - if: '$CI_PIPELINE_SOURCE == "web"'
      variables:
        - CI_COMMIT_TAG: "manual"

build_app:
  script:
    - echo "Build completed"
  artifacts:
    expire_in: 30 days
    paths:
      - .
    name: "app-$CI_COMMIT_TAG"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.