gitlab

Waiting custom time between stages


I want the "verify" stage does not to start running after "test" stage is completed, I want the "verify" stage to start running X minutes after completion of the "test" is completed.

stages:
  - configure-site
  - test
  - verify

Solution

  • You could add a new stage in between the "test" and "verify" stage. That stage could simply execute a "sleep" command with the given time in seconds.

    Otherwise, you could add the sleep-command to the end of your "test"-job.

    Please be aware, that a job cannot run longer than 60 minutes per default (docs).

    stages:
      - configure-site
      - test
      - wait
      - verify
    
    configure-site:
      stage: configure-site
      ...
    
    test:
      stage: test
      needs:
        - "configure-site"
      ...
    
    wait:
      stage: wait
      needs:
        - "test"
      script:
        - sleep 600
    
    verify:
      stage: verify
      needs:
        - "wait"
      ...
    

    However, as the comments to your question already stated, I would tend to amend your jobs process to alert the CI when the publishing is finished, instead of just waiting for a specified time. I think, the "test" job should automatically wait until everything is really finished, instead of starting some process and returning some kind of success without knowing if the process really was successful.

    Otherwise, maybe you could use the external status checks to ensure your publishing job is executed after the tests. Your external job could than call the API when the process is finished (Gitlab collective article).