I have gitlab project with ci file:
stages:
 - build
 - run
build:
  stage: build
  script:
    - (some stuff)
  tags:
    - my_runner_tag
  except:
    - triggers
  when: manual
run:
  stage: run
  script:
    - (some stuff)
  tags:
    - my_runner_tag
  except:
    - triggers
  when: manual
Jobs are created on every source code change, and they can be run only manually, using gitlab interface.
Now, i want to have possibility to trigger stage run with Gitlab API. Trying:
curl -X POST \
>      -F token=xxxxxxxxxxxxxxx \
>      -F ref=master \
>      https://gitlab.xxxxx.com/api/v4/projects/5/trigger/pipeline
Returns:
{"message":{"base":["No stages / jobs for this pipeline."]}}
Seems, like i have to define stage to trigger, but i can't find a way to pass it via api call.
you are using the wrong endpoint, to do it, you need to follow the path below
list all of your pipelines and get the newest one
GET /projects/:id/pipelines
list the jobs from this pipeline
GET /projects/:id/pipelines/:pipeline_id/jobs
After that you can trigger your job
POST /projects/:id/jobs/:job_id/play
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With