3

I have a scheduled pipeline in gitlab, whose description is "run everyday".

similar to this https://docs.gitlab.com/ee/ci/pipelines/schedules.html

How can I fetch this description when the pipeline runs? is there any CI variable which could give me the description?

Naresh
  • 41
  • 3
  • These are all the pre-defined variables available in Gitlab. Doesn't look like that description can be fetched https://docs.gitlab.com/ee/ci/variables/predefined_variables.html – TheGeorgeous Nov 02 '20 at 05:56
  • 1
    I don"t think it's possible, but you can maybe define a variable on your schedule such as `MY_SCHEDULE_DESC` and define it as the same value as your schedule's description? – Pierre B. Nov 02 '20 at 13:19

2 Answers2

2

You could configure a variable within the schedule run.

Then use it within your gitlab-ci.yml file to achieve what you wanted. (Like pierres comment)

quizguy
  • 161
  • 9
0

I have good news!!
Our friends at GitLab have been working on this feature. There is now a way to label your pipeline in release 15.5.1-ee.0!

https://docs.gitlab.com/ee/ci/yaml/#workflow

It uses the workflow control with a new keyword name

workflow:
    name: 'Pipeline for branch: $CI_COMMIT_BRANCH'

You can even use the workflow:rules pair to have different names for you pipeline:

variables: PIPELINE_NAME: 'Default pipeline name'

workflow:
    name: '$PIPELINE_NAME'
rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
       variables:
           PIPELINE_NAME: 'MR pipeline: $CI_COMMIT_BRANCH'
    - if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-in-ruby3/'
       variables:
           PIPELINE_NAME: 'Ruby 3 pipeline'

This feature is disabled by default in 15.5 because it is so new.

You can enable the feature flag, which is named pipeline_name.
See this link to enable: https://docs.gitlab.com/ee/administration/feature_flags.html

You need to use the Rails Console to enable it. Pretty easy.

Note: Remember that the workflow keyword affects the entire pipeline instance.

Traveler_3994
  • 147
  • 1
  • 10
  • I don't think that this is what OP is asking. They want to access the scheduler name from within the .gitlab-ci.yml that is run, not the Pipeline name, preferably from some setting that already exists in GitLab. – k-den Feb 17 '23 at 16:41