14

Let's say I have these stages defined in .gitlab-ci.yml:

stages:
    - build
    - analysis
    - tests
    - deploy
    - post-deploy

Since analysis takes a lot of time and I don't really care about the result (I also have allow_failure: true set) - is it possible to somehow define to start analysis and then immediately launch the next stage tests?

I didn't find any reference to similar topic on official docs.

EDIT:

The main idea is that all other stages can be run as if the analysis didn't even exist. If i put analysis to same stage as tests, then both analysis and tests will run at the same time, however deploy won't be launched until both of them finish. This is no good. I want tests to finish and then launch deploy, after deploy finishes I want to launch post-deploy. I really don't care about analysis result, I simply want to trigger it and continue with the deployment.

WellBloud
  • 927
  • 4
  • 13
  • 29

3 Answers3

14

Since v12.8, you can use needs: [] to start jobs start immediately. Docs: https://docs.gitlab.com/ee/ci/yaml/#needs

Mikhail Vasin
  • 2,421
  • 1
  • 24
  • 31
  • To be clear: the jobs will run immediately **only** if explicitly setting `needs: []`, right? otherwise they are strictly serial as the [accepted answer](https://stackoverflow.com/a/47287038/3165014) suggests? – sox supports the mods Jul 10 '23 at 16:23
3

There's a workaround available in newer GitLab versions: Trigger a child-pipeline for the jobs you don't want to wait for. By default a child-pipeline will return "success" as soon after it got started, you need to explicitly set the strategy if you'd like to wait for the jobs in the child-pipeline. So by accident this is exactly the behaviour you'd like to have.

The UI is not the best right now, but I'm positive it'll improve in future versions of GitLab. It's a workaround after all, but it should do the job.

MOnsDaR
  • 8,401
  • 8
  • 49
  • 70
1

Stages are per definition serial. One stage will be executed after another.

If you want to process analysis and tests parallelly, you have to define them on the same stage.

stages: 
 - build
 - processing
 - deploy
 - ...

analysis:
 stage: processing
 ...


tests:
 stage: processing
 ...

https://docs.gitlab.com/ce/ci/yaml/README.html#stage

acm
  • 2,086
  • 3
  • 16
  • 34
secustor
  • 3,001
  • 2
  • 14
  • 20
  • 1
    Maybe I wasn't clear enough in my question. I know about this option, however in this scenario if tests finished the rest of stages (deploy, post-deploy) will still be waiting on analysis to finish. Is it possible to start analysis and continue with the rest as if the analysis wasn't in the stages? – WellBloud Nov 15 '17 at 14:34
  • I have edited my question, so it's (hopefully) more clear – WellBloud Nov 15 '17 at 15:05
  • 1
    I see. There is no such feature. As the concept of the stages is strictly linear. As you don't need the result of the analysis, I would simply add it at the end. – secustor Nov 15 '17 at 16:13