I have a curl command (see below), currently I have one job in my pipeline and when I execute the curl command below, it runs my pipeline and executes my only job, i.e test-job1. Now I have added test-job2. I will have more jobs in there, but I want to be able to configure the jobs such that I can pick and choose the jobs (create rule in the jobs essentially) such that I can run those particular jobs and only those jobs by curl command.
Can anyone provide me with all the steps?
curl --request POST "https://gitlab.example.com/api/v4/projects/1412/pipeline" \
--header "Content-Type: application/json" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data @variables.json
build-job:
stage: build
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
test-job1:
stage: test
script:
- python3 mydumbscript.py $arg1 $arg2 $arg3
how to run particular jobs in gitlab ci/cd via gitlab api?
test-job2:
stage: test
script:
- echo "This job tests something, but takes more time than test-job1."
- echo "After the echo commands complete, it runs the sleep command for 20 seconds"
- echo "which simulates a test that runs 20 seconds longer than test-job1"
- sleep 20
deploy-prod:
stage: deploy
script:
- echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
environment: production