Gitlab: trigger manual action via API

The API call you’re using is to trigger the step, not to start it manually. If you change your job definition to accept triggers or manual actions, then your current API call would work. We can do this with the rules keyword:

  stage: test
    - echo test
  when: manual
    - if: “$CI_PIPELINE_SOURCE == ‘trigger’”
       when: always

What this does is set the default to manual so it can still be started in the UI, but also check the $CI_PIPELINE_SOURCE predefined variable to see if the pipeline was triggered. If so, it will always run.

You can see the docs for the rules keyword here: and all of the predefined variables here:

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top