.gitlab-ci.yml and saving API endpoint values in variables?

Good day, I have a variable as follows in my .gitlab-ci.yml file:

$PIPELINE_ID = (Invoke-RestMethod -Uri 'https://gitlab.example/api/v4/projects/1/pipelines/latest').id

Is this the correct way to capture values from the JSON response from that API call into a variable? This is the full response:


Thanks for any tips / help

Hi @Calicoder

Variables are just strings, you cannot execute subshell commands in them.

If you need to get Pipeline ID the job is part of you can use one of many Predefined variables reference | GitLab

1 Like

Perfect, thank you for the tip