2021-02-22 17:27:13 +05:30
|
|
|
image: openshift/origin-cli
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
stages:
|
2019-09-04 21:01:54 +05:30
|
|
|
- build # dummy stage to follow the template guidelines
|
2017-08-17 22:00:37 +05:30
|
|
|
- test
|
2019-09-04 21:01:54 +05:30
|
|
|
- deploy # dummy stage to follow the template guidelines
|
2017-08-17 22:00:37 +05:30
|
|
|
- review
|
|
|
|
- staging
|
|
|
|
- production
|
|
|
|
- cleanup
|
|
|
|
|
|
|
|
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"
|
|
|
|
script:
|
|
|
|
- "oc get services $APP 2> /dev/null || oc new-app . --name=$APP --strategy=docker"
|
2018-03-17 18:26:18 +05:30
|
|
|
- "oc start-build $APP --from-dir=. --follow || sleep 3s && oc start-build $APP --from-dir=. --follow"
|
2017-08-17 22:00:37 +05:30
|
|
|
- "oc get routes $APP 2> /dev/null || oc expose service $APP --hostname=$APP_HOST"
|
|
|
|
|
|
|
|
review:
|
|
|
|
<<: *deploy
|
|
|
|
stage: review
|
|
|
|
variables:
|
2018-03-17 18:26:18 +05:30
|
|
|
APP: review-$CI_COMMIT_REF_NAME
|
2017-08-17 22:00:37 +05:30
|
|
|
APP_HOST: $CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
|
|
|
|
environment:
|
|
|
|
name: review/$CI_COMMIT_REF_NAME
|
|
|
|
url: http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
|
|
|
|
on_stop: stop-review
|
2021-06-08 01:23:25 +05:30
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
stop-review:
|
|
|
|
<<: *deploy
|
|
|
|
stage: cleanup
|
|
|
|
script:
|
|
|
|
- oc delete all -l "app=$APP"
|
|
|
|
variables:
|
2018-03-17 18:26:18 +05:30
|
|
|
APP: review-$CI_COMMIT_REF_NAME
|
2017-08-17 22:00:37 +05:30
|
|
|
GIT_STRATEGY: none
|
|
|
|
environment:
|
|
|
|
name: review/$CI_COMMIT_REF_NAME
|
|
|
|
action: stop
|
2021-06-08 01:23:25 +05:30
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
|
|
|
when: manual
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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
|
2021-06-08 01:23:25 +05:30
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
production:
|
|
|
|
<<: *deploy
|
|
|
|
stage: production
|
|
|
|
variables:
|
|
|
|
APP: production
|
|
|
|
APP_HOST: $CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
|
|
|
|
environment:
|
|
|
|
name: production
|
|
|
|
url: http://$CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
|
2021-06-08 01:23:25 +05:30
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
|
|
when: manual
|