79438950

Date: 2025-02-14 09:51:31
Score: 0.5
Natty:
Report link

On our gitlab instance (currently running GitLab Community Edition v17.5.5) we have a ci pipeline which works quite well setting dynamic environment properties through variables like so:


[... workflow, stages...]

variables:
  STAGE_NAME: "our-app-$CI_COMMIT_REF_SLUG"
  DEPLOYMENT_HOST: "$STAGE_NAME.our.domain"

[...build etc...]

deploy_review:
  stage: deploy
  script:
    - echo "Deploying tag $CI_COMMIT_REF_SLUG to stage $STAGE_NAME at $DEPLOYMENT_HOST"
    - ./actually_do_your_helm_or_whatever_deployment.sh
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: https://$DEPLOYMENT_HOST
    on_stop: destroy
    auto_stop_in: 14 days
    deployment_tier: development

destroy:
  stage: deploy
  variables:
    GIT_STRATEGY: none
  script:
    - echo "Removing stage $STAGE_NAME at $DEPLOYMENT_HOST"
    - ./your_tear_down_script.sh
  environment: 
    name: review/$CI_COMMIT_REF_NAME
    action: stop
  when: manual

See here for details:

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Echsecutor