Manual CI job not allow to be triggered with "You are not authorized to run this manual job" message

Can not run manual CI job

I have CI pipeline with multiple jobs. Once all the automatic jobs are finished there are some manual jobs that can be triggered.

These are rough steps contained in our pipeline:

  • Lint
  • Build
  • Pack
  • Store
  • Deploy (manual)

The issue that I am facing is with manual CI job Deploy. Sometimes the job cannot be triggered, the play button is greyed out and “You are not authorized to run this manual job” tooltip message is shown on hover.

I do not have any Protected environments set. User that is trying to trigger the job has all permissions (administrator).

This is a bit simplified version of the job:

DeployToServer1:
  stage: deploy
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "release" || $CI_COMMIT_BRANCH == "master" || $CI_PIPELINE_SOURCE == "merge_request_event"'
      when: manual
      allow_failure: true
    - when: never
  needs: ["JobA"]
  script:
    - .\upgrade.ps1 'C:\some\path' 'someParameter'
  environment:
    name: qa/Server1
  tags:
    - QAServer1

Why am I getting “You are not authorized to run this manual job”?

One reason might be that the job is obsolete, as explained here: Deployment safety | GitLab
The behavior has changed in version 15.5, it was improved but as a consequence this error started to appear in some of our pipelines where we have multiple deployments to the same environment