Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create manually-run GitLab pipeline jobs?

Tags:

gitlab

I would like to know how to manually trigger specific jobs in a project's CI pipeline. Since there is only one gitlab-ci.yml file, I can define many jobs to be executed one after the other sequentially. But what if I want to start a manual CI pipeline that only carries out one job? As I understand it, every time the pipeline will run, it will run all jobs, unless I use many only and similar parameters. For instance, when I have this simple pipeline config:

stages:
    - build

build:
    stage: build
    script:
        - npm i
        - npm run build
        - echo "successful build"

What do I do if I want to only run an echo job that runs a simple echo "hello" script, but does only that and only when I manually run it? There are no 'triggers' for a job like that afaik. Is this even a possibility?

Thanks for the clarification!

like image 644
Jonathan Bareket Avatar asked Aug 28 '20 11:08

Jonathan Bareket


1 Answers

Apparently, the solution is pretty simple, just needed to add a when: manual paramater to the job:

echo:
    stage: echo
    script:
        - echo 'this is a manual job'
    when: manual

Once that's done, the job can be triggered independently right here: enter image description here

like image 131
Jonathan Bareket Avatar answered Oct 02 '22 13:10

Jonathan Bareket