0

I want to automate building and deploying of projects. In this regard, I want to use GItlab API to retry particular jobs in Gitlab Pipeline.

The API call I make as follows:

curl --request POST --header "PRIVATE-TOKEN: xxx" "https://gitlab.example.com/api/v4/projects/1/jobs/1/retry"

My Job otherwise can be triggered manually and my gitlab-ci.yml file looks like this:

execute_octoDeploy:
  tags:
    - windows
  stage: build
  when: manual
  script:
    - .\BuildScripts\octodeploy.ps1

I get 403 error, which according to https://docs.gitlab.com/ee/api/README.html means that I am not authorized. Whereas I have all the rights of the project and I am the owner of the same.

To add: I can trigger other non-manual jobs but not this. I also referred: https://gitlab.com/gitlab-org/gitlab-ce/issues/22824

What might be wrong? How can I solve this?

Padma Channal
  • 94
  • 1
  • 13

1 Answers1

0

I seem to have found the solution for this:

  • You need to add scope of the jobs in the API call
  • Also Retry method will work only when you have canceled your job in that pipeline.

You can try:

curl --header "PRIVATE-TOKEN: xxxxx" 'https://gitlab.example.com/api/v4/projects/1/jobs?scope[]=pending&scope[]=running'

and then specify if you want to play/retry a job.

Padma Channal
  • 94
  • 1
  • 13