Commit 8c08f582 authored by Mark Pundsack's avatar Mark Pundsack
Browse files

Update for Openshift

parent c39b39d8
image: ayufan/openshift-cli
image: alpine
stages:
- build
- test
- review
- staging
- production
variables:
# Configure these variables in Secure Variables:
# OPENSHIFT_SERVER: https://openshift.domain.com:8443
# OPENSHIFT_SERVER: openshift.default.svc.cluster.local
# OPENSHIFT_TOKEN: my.openshift.token
# OPENSHIFT_DOMAIN: routes.openshift.domain.com
before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" --insecure-skip-tls-verify
- oc project "$CI_PROJECT_NAME"
build:
stage: build
before_script: []
script:
- echo build
test1:
stage: test
before_script: []
script:
- echo run tests
test2:
stage: test
before_script: []
script:
- echo run tests
.deploy: &deploy
image: ayufan/openshift-cli
before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" --insecure-skip-tls-verify
- oc project "$CI_PROJECT_NAME"
script:
- oc get services $APP || oc new-app . --name=$APP --strategy=docker
- oc get routes $APP || oc expose service $APP --hostname=$APP_HOST
- oc start-build $APP --from-dir=. --wait
production:
review:
<<: *deploy
stage: production
stage: review
variables:
APP: production
APP_HOST: production.$OPENSHIFT_DOMAIN
APP: raoc-$CI_BUILD_REF_NAME
APP_HOST: $CI_PROJECT_NAME-$CI_BUILD_REF_NAME.review.$OPENSHIFT_DOMAIN
environment:
name: review/$CI_BUILD_REF_NAME
url: http://$CI_PROJECT_NAME-$CI_BUILD_REF_NAME.review.$OPENSHIFT_DOMAIN
on_stop: stop-review
only:
- branches
except:
- master
stop-review:
<<: *deploy
stage: review
script:
- oc delete all -l "app=$APP"
when: manual
variables:
APP: raoc-$CI_BUILD_REF_NAME
GIT_STRATEGY: none
environment:
name: production
url: http://production.$OPENSHIFT_DOMAIN
name: review/$CI_BUILD_REF_NAME
action: stop
only:
- branches
except:
- master
staging:
<<: *deploy
stage: staging
variables:
APP: staging
APP_HOST: staging.$OPENSHIFT_DOMAIN
APP: raoc-staging
APP_HOST: $CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
environment:
name: staging
url: http://staging.$OPENSHIFT_DOMAIN
url: http://$CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
only:
- master
review:
production:
<<: *deploy
stage: staging
stage: production
variables:
APP: review-$CI_BUILD_REF_NAME
APP_HOST: $CI_BUILD_REF_NAME.review.$OPENSHIFT_DOMAIN
APP: roac-production
APP_HOST: $CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
when: manual
environment:
name: review/$CI_BUILD_REF_NAME
url: http://$CI_BUILD_REF_NAME.review.$OPENSHIFT_DOMAIN
name: production
url: http://$CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
only:
- branches
except:
- master
# Updated README
# This is an example project that shows how to use Review Apps
This is a very basic project that has one static page, but it shows how to use
the environments feature of GitLab and the recently introduced dynamic
environments which can be used for Review Apps.
Review Apps allow you to create a new environment for each of your branches.
This review app is then visible as a link when you visit the merge request
for the branch. That way you are able to see all changes
introduced by the merge request changes, running live.
The example here uses a set of 3 environments:
1. `production`: you trigger deploys to production manually, by clicking the **Production**
action under the **Pipelines** tab of your project.
1. `staging`: staging is deployed automatically when changes to `master` get
merged.
1. `review/*`: the review app is created for any other branch that is pushed to GitLab.
## Access the example
This project can be accessed under these addresses:
1. `production`: http://review-apps-openshift.138.68.69.232.xip.io/
1. `staging`: http://review-apps-openshift-staging.138.68.69.232.xip.io/
1. `review` for merge request !1: http://review-apps-openshift-update-hello-world.138.68.69.232.xip.io/
## Use it for your projects
This is a very simple example, but you can adapt it for your needs and have a
page that is deployed dynamically.
To do that you have to follow these few simple steps.
1. [Optional] Install GitLab on Openshift (version 1.3.1)
```
oc login
oc new-project gitlab
wget https://gitlab.com/gitlab-org/omnibus-gitlab/raw/openshift-template/docker/openshift-template.json
oc create -f openshift-template.json
```
1. Add a Secure Variable with your Openshift token, server address, and app domain
Add a `OPENSHIFT_TOKEN, `OPENSHIFT_SERVER`, and `OPENSHIFT_DOMAIN` to Secure Variables
You can now start pushing your changes and see them live!
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment