Is there alternative to GitLab's Protected environments?

Viewed 373

Protected environments are available only on premium tier. Are there any alternatives to use on free? I've been researching this topic for a while and for now I have one idea - use multi-project pipelines. But this solution adds a little too much complexity.

2 Answers

You could do the following to at least mimic protected environments a bit.

  • Create a repo with only the deploy job in its gitlab-ci.yml.
  • In your job which you want to be protected call the pipeline in the above repo with a multi-project-pipeline
  • Only grant certain users developer/maintainer access to your protected repo
  • Only users with access to the protected repo can now run the manual job, all other users will get an error
deploy_prod:
  stage: deploy
  trigger:
    project: group/protected-repo
    strategy: depend
  environment:
    name: production
    url: https://example.com
  when: manual
  only:
     - master

Hence my goal was to restrict running manual jobs on pipelines for users - I have found that protected branches and protected variables will be the best solution I have so far.

Then just restrict who can merge/push co protected branches and automatically only those people will be able to trigger manual jobs in those branches.

Related