GitLab CI - How can run only one manual job, and disable the others after it has ran?

Viewed 30

I have multiple manual jobs, where only one needs to be selected. Once one is selected I want to disable the other jobs. In this example I have 3 npm jobs, once the dev chooses one of these, I want to disable the other two jobs from being able to run. I was going to add a needs dependency but that only allows you to select a job that has already run.

Here is what I have so far:

publish_patch:
  stage: deploy
  image: node:latest
  before_script:
    - cp $SCRT_NPMRC_TOKEN .npmrc
  script:
    - npm version patch
    - npm publish
    - git checkout main
    - git add package.json package-lock.json
    - git commit -m "automatic version commit" 
    - git push -o ci.skip
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_BRANCH
  when: manual

publish_minor:
  stage: deploy
  image: node:latest
  before_script:
    - cp $SCRT_NPMRC_TOKEN .npmrc
  script:
    - npm version minor
    - npm publish
    - git checkout main
    - git add package.json package-lock.json
    - git commit -m "automatic version commit" 
    - git push -o ci.skip
  when: manual


publish_major:
  stage: deploy
  image: node:latest
  before_script:
    - cp $SCRT_NPMRC_TOKEN .npmrc
  script:
    - npm version patch
    - npm publish
    - git checkout main
    - git add package.json package-lock.json
    - git commit -m "automatic version commit" 
    - git push -o ci.skip
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_BRANCH
  when: manual

0 Answers
Related