Detect pipeline test stage job change via API

I have been reviewing through the api doc and cant seem to see a way to detect a pipeline change.
For example, if a typical pipeline would consist of the below stages, is it possible with the API to detect a change from test1 to test2 in the test stage?

A build stage, with a job called compile.
A test stage, with two jobs called test1 and test2.
A staging stage, with a job called deploy-to-stage.
A production stage, with a job called deploy-to-prod

I was hopeful the answer would lie in this portion of the api but no joy so far

Any guidance at all would be greatly appreciated.

I think you might find some interest in the Jobs API:

In particular, listing the pipeline jobs:

GET /projects/:id/pipelines/:pipeline_id/jobs

The response will show each job, including a job name and a status. One such status is ‘pending’, another is ‘running’, etc. If you have a polling loop from the outside, you might be able to detect when test2 goes from ‘pending’ to ‘running’ (or, if the job is faster than your polling interval, perhaps to ‘success’, ‘failure’, or maybe even ‘canceled’)

One warning: If the jobs are in the same stage, I don’t think GitLab enforces a particular execution order, and they could run concurrently, if you’ve got enough runners. I suspect you’ve thought of that, but I wanted to mention it just in case.

Another idea, if you have control over your pipeline scripts, you could consider putting some code in the after_script of test1 or the before_script of test2 to push a notification to wherever you need to know about the change.

1 Like

Thank you very much for your response, super helpful !