How to make a stage optional

How to make a stage optional

For publishing my app to the apple & playstore, I did create a staging stage which send it as a test version. Most of the case this is ok, since we should test first before releasing. But sometime we did a changed that we know won’t have to be tested.
This is the reason why I need to have this stage, but would like to be able to skip this and run directly the production stage

In resume : on publishing a new version

  1. Building - when: automatic - obligated
  2. Staging - when: automatic - skippable
  3. Producton - when: manual - optional

actually I’m forced to wait for the staging to be finished, or do I?
I couldn’t find any help in the documentation.

I know, I could create only one stage, but it’s visually easier to read it like that :

Hi @r.balet
you could use rules: to specify under which condition should jobs run in 2nd stage.

I want the 2nd stage to run, but I want it to be skippable if needed, and then be able to run the 3nd stage without having to wait for the 2nd to be rune & finish. I’m not sure but the rules: doesn’t seems to me to make this possible

Maybe you can clarify what do you mean by ‘optional’ or ‘skippable’. Jobs are either executed or not based on conditions you set. You need to tell GitLab when do you want to execute the jobs and when not.

If you need the 2nd stage to be (based on some conditions) sometimes executed and sometimes not executed before 3rd stage rules: can achieve that.

If you don’t care about the outcome of 2nd stage, but want to go directly to 3rd stage
you can use needs keyword. This allows you to run jobs from multiple stages at the same time. You can see more in the docs.

But then all your jobs in 3rd stage are manual, so why not just put the jobs from 2nd stage there as well and run the manual jobs as you need.

1 Like

This is purely for a better UI purpose.

If I move the staging branch under the production build, then.

  1. We won’t see clearly enough the difference between the two jobs, which may result in error, running the wrong one.
  2. It will be longer to find it, since it will be somewhere in the list, which have around 30 jobs
  3. I wont be able to manually trigger every jobs without the staging stage which may be useful.

the needs keyword seems to be exactly what I was searching for, thx a lot.