Using CI/CD components with "manual" rule

Using CI/CD components with “manual” rule

I have created a CI/CD component that encapsulates a recurring job in our pipelines. The job provided by this component should be a “manual” job in case of a merge request pipeline. I.e. it should not be executed automatically for a merge request but it is an optional “manual” job.

The configuration in the .gitlab-ci.yml file looks like:

include:
  - component: <repo-path>/<component-name>@1.0
    inputs:
      stage: build
    rules:
      - if: $CI_PIPELINE_SOURCE == "merge_request_event"
        when: manual

When the pipeline is triggered for a merge request, the following error message is shown:

This GitLab CI configuration is invalid: include:rule when unknown value: manual.

When I remove the ‘when: manual’ line then no error occurs.

Reading the GitLab documentation I have not found a hint that ‘manual’ is not supported/allowed here. Does anyone have tried executing manual jobs in combination with CI/CD components? Does this work in general or is it currently not supported?

2 Likes

We want to achieve a similar goal, but face this issue with “when: manual”. We also cannot find any documentation on using rules along components, other than seeing that in public CICD components this is successfully used, but never in combination with “when: manual”. Looking forward to any new response here. Or maybe you woelfie have made progress and would like to share? Thank you!

Using ‘manual’ is currently not supported with ‘include’. This documented in the CI/CD YAML reference, as we found out.

Below the header of the section Use CI/CD configuration from other files | GitLab there is a ‘…’ button. Clicking that button expands a section where it is documented that only ‘never’ and ‘always’ are supported

Hello woelfle,

thank you very much for your response! This helps us in deciding how to go forward with our CICD components.

The only chance we see here is to work with variables for now. This works in most of the cases for us, but in some, we’d like to have full flexibility regarding which and how many rules should be applied and also allowing “when: manual”. This is somewhat difficult to achieve with variables only. Do you also have this use case and have you found a workaround for that?

Hi Widura,

We have not found a viable solution for this problem until now. For some cases we are working with global variables too but this is only a workaround that, as you mentioned, does not work for all cases.