Skip to content
Snippets Groups Projects
Verified Commit eedc8e2b authored by Chris Coley's avatar Chris Coley
Browse files

Finalizing on variable substituion in .pre stage job

parent cb19f164
Branches
No related tags found
1 merge request!5Variable substitution
...@@ -5,6 +5,15 @@ workflow: ...@@ -5,6 +5,15 @@ workflow:
rules: rules:
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
# We can't do variable substitution in a job and then also use that computed
# variable in the Environment URL of the same job, so we have to do the
# substitution in an earlier stage. All of this variable substitution is only
# required for projects in sub-groups because GitLab doesn't have a predefined
# variable that contains the project namespace relative to the root namespace.
#
# For example, if the project path is "/group/subgroup-1" then we need just the
# "/subgroup-1" portion because that is used in the Environment URL path, while
# the "/group" root namespace is used as the subdomain.
setup: setup:
stage: .pre stage: .pre
tags: tags:
...@@ -16,16 +25,14 @@ setup: ...@@ -16,16 +25,14 @@ setup:
dotenv: build.env dotenv: build.env
# We can't deploy multiple different variants of GitLab Pages sites (e.g. one # We can't deploy multiple different variants of GitLab Pages sites (e.g. one
# per branch), so we use this quick instead. GitLab has a special browsable URL # per branch), so we use this workaround instead. GitLab has a special browsable
# for job artifacts on public projects, and we can create an Environment that # URL for job artifacts on public projects, and we can create an Environment
# points to that URL so it's easy for devs to know what the current Environment # that points to that URL so it's easy for devs to know what the current
# URL for their branch is. # Environment URL for their branch is.
.deploy: .deploy:
stage: deploy stage: deploy
tags: tags:
- docker - docker
variables:
PROJECT_SUB_NAMESPACE: /
script: script:
- sed -i "s/%%BRANCH%%/$CI_COMMIT_BRANCH/g" src/index.html - sed -i "s/%%BRANCH%%/$CI_COMMIT_BRANCH/g" src/index.html
- mv src public - mv src public
...@@ -40,15 +47,7 @@ setup: ...@@ -40,15 +47,7 @@ setup:
# Deploy a review environment for any push to a branch that is not the default # Deploy a review environment for any push to a branch that is not the default
# branch # branch
review-sub: review:
extends: .deploy
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
environment:
name: "review-sub $CI_COMMIT_BRANCH"
url: "https://${CI_PROJECT_ROOT_NAMESPACE}.${CI_PAGES_DOMAIN}/-${PROJECT_SUB_NAMESPACE}${CI_PROJECT_NAME}/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
review-rel:
extends: .deploy extends: .deploy
rules: rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment