.gitlab-ci.yml 1.98 KB
Newer Older
Arman Khalatyan's avatar
Arman Khalatyan committed
1
# This file is a template, and might need editing before it works on your project.
Arman Khalatyan's avatar
Arman Khalatyan committed
2
image: openshift/origin-cli
Arman Khalatyan's avatar
Arman Khalatyan committed
3

Arman Khalatyan's avatar
Arman Khalatyan committed
4

Arman Khalatyan's avatar
Arman Khalatyan committed
5

Arman Khalatyan's avatar
Arman Khalatyan committed
6 7 8
default:
  tags:
    - okd
Arman Khalatyan's avatar
Arman Khalatyan committed
9
  timeout: 1h 00m
Arman Khalatyan's avatar
Arman Khalatyan committed
10

Arman Khalatyan's avatar
Arman Khalatyan committed
11 12 13 14 15 16 17
stages:
  - test
  - staging
  - production
  - cleanup

variables:
Arman Khalatyan's avatar
Arman Khalatyan committed
18 19
  OPENSHIFT_SERVER: https://${OPENSHIFT_IP}:${OPENSHIFT_PORT}/
  OPENSHIFT_DOMAIN: apps.okd.aip.de
Arman Khalatyan's avatar
Arman Khalatyan committed
20
  # Configure this variable in Secure Variables:
Arman Khalatyan's avatar
Arman Khalatyan committed
21
  #OPENSHIFT_TOKEN: 
Arman Khalatyan's avatar
Arman Khalatyan committed
22 23
  #OPENSHIFT_PROJECT: python

Arman Khalatyan's avatar
Arman Khalatyan committed
24 25 26 27 28
test1:
  stage: test
  before_script: []
  script:
    - echo run tests
Arman Khalatyan's avatar
Arman Khalatyan committed
29

Arman Khalatyan's avatar
Arman Khalatyan committed
30 31 32 33 34
test2:
  stage: test
  before_script: []
  script:
   - echo run tests
Arman Khalatyan's avatar
Arman Khalatyan committed
35 36 37 38 39 40 41 42

.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"
    - "oc start-build $APP --from-dir=. --follow || sleep 3s && oc start-build $APP --from-dir=. --follow"
Arman Khalatyan's avatar
Arman Khalatyan committed
43
    - "oc get routes $APP 2> /dev/null || oc create route edge $APP --service $APP --insecure-policy Redirect" 
Arman Khalatyan's avatar
Arman Khalatyan committed
44 45 46 47 48 49 50 51 52 53


staging:
  <<: *deploy
  stage: staging
  variables:
    APP: staging
    APP_HOST: $CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
  environment:
    name: staging
Arman Khalatyan's avatar
Arman Khalatyan committed
54
    url: https://$CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
Arman Khalatyan's avatar
Arman Khalatyan committed
55 56 57 58 59 60 61 62 63 64 65
  only:
    - master

production:
  <<: *deploy
  stage: production
  variables:
    APP: production
    APP_HOST: $CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
  environment:
    name: production
Arman Khalatyan's avatar
Arman Khalatyan committed
66
    url: https://$CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
Arman Khalatyan's avatar
Arman Khalatyan committed
67 68
  only:
    - master
Arman Khalatyan's avatar
Arman Khalatyan committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82

stop-project:
  <<: *deploy
  stage: cleanup
  script:
    - oc delete all -l "app=$APP"
  when: manual
  variables:
    APP: production
  environment:
    name: production
    action: stop
  only:
    - master
Arman Khalatyan's avatar
Arman Khalatyan committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96
  
stop-staging:
  <<: *deploy
  stage: cleanup
  script:
    - oc delete all -l "app=$APP"
  when: manual
  variables:
    APP: staging
  environment:
    name: staging
    action: stop
  only:
    - master