0

Currently I have such pipeline structure:

Lint Test Deploy
lint test-int pages
test-stg

What I would like to do is when I execute either test-int or test-stg to execute / re-run the pages job to upload the latest artifacts.

What I managed to do so far is to execute the pages job when test-int is manually executed for the first time. If I manually re-run test-int, the pages job is not executed again..

Here is my script:

image: mcr.microsoft.com/playwright:v1.27.0-focal

before_script:
  - npm ci

stages:
  - lint
  - test
  - deploy

lint:
  stage: lint
  tags:
    - build
    - docker
  script:
    - npx eslint . --ext .cjs,.js,.ts
    - npx gherkin-lint
  only:
    - branches
    - tags

test-int:
  stage: test
  tags:
    - dev
    - gib
    - docker
  script:
    - npm run test:int
  only:
    - branches
    - tags
  when: manual

test-stg:
  stage: test
  tags:
    - dev
    - gib
    - docker
  script:
    - npm run test:stg
  only:
    - branches
    - tags
  when: manual

pages:
  stage: deploy
  needs:
    - test-int
  tags:
    - dev
    - gib
    - docker
  script:
    - echo "Deploying automation reports to Gitlab Pages..."
  artifacts:
    paths:
      - public
  only:
    - branches
    - tags
Ignas Damunskis
  • 1,515
  • 1
  • 17
  • 44

1 Answers1

0

By default, GitLab won't automatically retry already-completed jobs when you retry an earlier job.

You either have to:

  • rerun the whole pipeline
  • manually retry each already-completed job you want to run

In principle, depending on the details of your pipeline, you may be able to automate this by providing an API key to your job and use the API to introspect the pipeline to perform the 'manual retry' solution on the job(s) you want to run when necessary. It'll be up to you to decide what behavior you want and implement the logic in a script.

As a loose outline, you may have a after_script defined for your test-int job that, on success will:

  • calls the pipeline jobs API to retrieve the pipeline jobs to obtain the job IDs and determine if manual retrying for later job(s) is needed
  • If manual action is needed (i.e., is not the first run and the pages job already ran), call the retry job API with the relevant job ID(s) obtained from the first call

Writing your own service to response to pipeline event webhooks may also be leveraged to similar effect.

sytech
  • 29,298
  • 3
  • 45
  • 86