How to get a deployment id

Hi, I’m trying to use the approval deployment feature using the api, how can I get the deployment id in this example?

curl --data "status=approved&comment=Looks good to me" \
     --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/deployments/1/approval"

what variable should I use?

/projects/:id/deployments/:deployment_id/approval

`deployment_id` integer => The ID of the deployment.

how can I get deployment_id ? is it an env variable?

thanks!

1 Like

@roque.ing were you able to see the light here…? I have the same question as I’d like to save a changelog of which MRs were actually deployed and I need to have access to the Deployment inside the actual CI deploy job to trigger this.

For future reference, I didn’t find any environment variable available during a deploy stage job. So what I ended up doing was:

  • fetch all the deployments for the current environment that have the status running via the Deployments API of GitLab and TYPICALLY that would be the only one running. This might not be true depending on your workflow