How to run a specific job in gitlab CI

We encounter a problem when we need to perform one specific task in gitlab CI. We do not currently know how to solve this problem. We have multi-line tasks defined in ours .gitlab-ci.yml, but we only need to complete one task in our conveyors. How can you just start a single task, for example? job1or job2? We cannot use tagsor branchesas a software switch in our environment.

.gitlab-ci.yml:

before_script:
  - docker info

job1:
  script:
    - do something

job2:
  script:
    - do something
+6
source share
3 answers

> GitLab CI, -, , tags branches, .

, "" CI - GitLab CI. GitLab CI , . . , . , tags, commit messages branches .

. . , . .

+2
+2

, .

  • Jawad, , , .
  • , when: manual .
  • , , , .

  • , 4 .
  • ( ) job 1, job 2 job 4, NOT job3.
  • job 3 , .

  • , .
  • , helloTag.1, helloTag.2, helloTag.3... ..
  • develop master ( ), 3 ( 1, 2, 4)

    Please note that the third task is not in the pipeline

    enter image description here

  • Go to "Repository" → "Tags" → "New Tag"

    Give the tag a name that matches your regular expression significantly

    enter image description here

  • If we are in a tag with a name that begins with "helloTag.", We will have 1 stage (stage 3)

    Please note that no other steps are present here.

    enter image description here

File example .gitlab-ci

stages:
    - myStage1
    - myStage2
    - myStage3
    - myStage4

This is my first stage:
    stage: myStage1
    before_script:
        - echo "my stage 1 before script"
    script:
         - echo "my stage 1 script"
    except:
        - /^helloTag.*$/

This is my second stage:
    stage: myStage2
    before_script:
        - echo "my stage 2 before script"
    script:
         - echo "my stage 2 script"
    except:
        - /^helloTag.*$/

This is my third stage:
    stage: myStage3
    before_script:
        - echo "my stage 3 before script"
    script:
         - echo "my stage 3 script"
    only:
        - /^helloTag.*$/

This is my fourth stage:
    stage: myStage4
    before_script:
        - echo "my stage 4 before script"
    script:
         - echo "my stage 4 script"
    except:
        - /^helloTag.*$/

Hope this helps you.

+2
source

Source: https://habr.com/ru/post/1015976/


All Articles