gitlab-org--gitlab-foss/vendor/gitlab-ci-yml/OpenShift.gitlab-ci.yml

93 lines
2.1 KiB
YAML
Raw Normal View History

2017-01-09 09:24:25 -05:00
image: ayufan/openshift-cli
stages:
- test
- review
- staging
- production
- cleanup
2017-01-09 09:24:25 -05:00
variables:
OPENSHIFT_SERVER: openshift.default.svc.cluster.local
# OPENSHIFT_DOMAIN: apps.example.com
# Configure this variable in Secure Variables:
# OPENSHIFT_TOKEN: my.openshift.token
test1:
stage: test
before_script: []
script:
- echo run tests
test2:
stage: test
before_script: []
script:
- echo run tests
.deploy: &deploy
before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" --insecure-skip-tls-verify
- oc project "$CI_PROJECT_NAME-$CI_PROJECT_ID" 2> /dev/null || oc new-project "$CI_PROJECT_NAME-$CI_PROJECT_ID"
2017-01-09 09:24:25 -05:00
script:
- "oc get services $APP 2> /dev/null || oc new-app . --name=$APP --strategy=docker"
2017-11-07 14:07:28 -05:00
- "oc start-build $APP --from-dir=. --follow || sleep 3s && oc start-build $APP --from-dir=. --follow"
2017-01-09 09:24:25 -05:00
- "oc get routes $APP 2> /dev/null || oc expose service $APP --hostname=$APP_HOST"
review:
<<: *deploy
stage: review
variables:
2017-11-07 14:07:28 -05:00
APP: review-$CI_COMMIT_REF_NAME
2017-03-10 05:41:37 -05:00
APP_HOST: $CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
2017-01-09 09:24:25 -05:00
environment:
name: review/$CI_COMMIT_REF_NAME
2017-03-10 05:41:37 -05:00
url: http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
2017-01-09 09:24:25 -05:00
on_stop: stop-review
only:
- branches
except:
- master
stop-review:
<<: *deploy
stage: cleanup
2017-01-09 09:24:25 -05:00
script:
- oc delete all -l "app=$APP"
when: manual
variables:
2017-11-07 14:07:28 -05:00
APP: review-$CI_COMMIT_REF_NAME
2017-01-09 09:24:25 -05:00
GIT_STRATEGY: none
environment:
name: review/$CI_COMMIT_REF_NAME
2017-01-09 09:24:25 -05:00
action: stop
only:
- branches
except:
- master
staging:
<<: *deploy
stage: staging
variables:
APP: staging
APP_HOST: $CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
environment:
name: staging
url: http://$CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
only:
- master
production:
<<: *deploy
stage: production
variables:
APP: production
APP_HOST: $CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
when: manual
environment:
name: production
url: http://$CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
only:
- master