Gitlab-ci multi pipeline

Hi guys!

I have a question from gitlab-ci. I have a very simple pipeline which i can start with one button and all job will be run. Okay, this is nice.
stages:
- build
- test1
- test2
- deploy

build:
  stage: build
  image: alpine
  script:
    - echo "BUILD STAGE"
  when: manual
  allow_failure: false

test1:
  image: alpine
  stage: test1
  needs: [build]
  script:
    - if echo "${CI_COMMIT_MESSAGE}" | grep "hotfix"; then exit 0; fi
    - echo "test1 job"
    - apk add --no-cache curl
    - sh gitlab-noti.sh

test2:
  image: alpine
  stage: test2
  needs: [build]
  script:
    - if echo "${CI_COMMIT_MESSAGE}" | grep "hotfix"; then exit 0; fi
    - echo "test2 job"
    - apk add --no-cache curl
    - sh gitlab-noti.sh

deploy:
  stage: deploy
  image: alpine
  needs: [build]
  script:
    - echo "deploy"

My question is, it possible to deplucate these jobs in the same gitlab-ci with only manual options? So everything same expect the jobs need to run manual.
Or any other solution for this?
Thank you very much your help!

Sorry what do you mean but “jobs need to run manual” ? Can you elaborate a lil’ bit more?

Yes.
The main pipeline is the automatic. I run the first job manually and after comes job after job.
I want this same pipeline with manual start evry job. So 2 same pipeline with same jobs, just first i can start with 1 button and the second need to run manually every job.

This is a simple snippet I came up with. I have the docker tag, because I have loads of different runners on my Gitlab not just docker runners, so I needed to set that - you can just remove it.

stages:
  - build
  - test1
  - test2
  - deploy

build:
  tags:
    - docker
  stage: build
  image: alpine
  script:
    - echo "BUILD STAGE"
  when: manual
  allow_failure: false

test1:
  tags:
    - docker
  image: alpine
  stage: test1
  needs: [build]
  script:
    - echo "${CI_COMMIT_MESSAGE}"
    - echo "manualtest1 job"

test2:
  tags:
    - docker
  image: alpine
  stage: test2
  needs: [build]
  script:
    - echo "${CI_COMMIT_MESSAGE}"
    - echo "manualtest1 job"

deploy:
  tags:
    - docker
  stage: deploy
  image: alpine
  needs:
    - test1
    - test2
  script:
    - echo "deploy"


###################
### MANUAL JOBS ###
###################

manualbuild:
  tags:
    - docker
  stage: build
  image: alpine
  script:
    - echo "BUILD STAGE"
  when: manual
  allow_failure: false

manualtest1:
  tags:
    - docker
  image: alpine
  stage: test1
  when: manual
  needs:
    - manualbuild
  script:
    - echo "${CI_COMMIT_MESSAGE}"
    - echo "manualtest1 job"

manualtest2:
  tags:
    - docker
  image: alpine
  stage: test2
  when: manual
  needs:
    - manualbuild
  script:
    - echo "${CI_COMMIT_MESSAGE}"
    - echo "manualtest2 job"

manualdeploy:
  tags:
    - docker
  stage: deploy
  image: alpine
  when: manual
  needs:
    - manualtest1
    - manualtest2
  script:
    - echo "deploy"

you should look into DAG (docs link)


If my reply answers your questions, please mark it as the solution. Else provide more information.
Regards.

1 Like