gitlab-ci-helpers.yml 1.88 KB
Newer Older
1
variables:
2 3
  CI_REGISTRY_IMAGE: registry.uninett.no/$CI_PROJECT_PATH
  CI_REGISTRY_TAG: $CI_COMMIT_SHA-$CI_PIPELINE_ID
4 5 6 7

.docker:
  services:
    - name: docker:stable-dind
8
      command: [ "dockerd", "--host=tcp://0.0.0.0:2375", "--host=tcp://0.0.0.0:2376" ]
9 10 11 12
  image: docker:stable
  before_script:
    - mkdir -p "$HOME/.docker"
    - echo -n "$DOCKER_AUTH_CONFIG" >"$HOME/.docker/config.json"
13 14 15 16

.docker-build:
  extends: .docker
  script:
17
    - docker build -t "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG" --label "no.uninett.scm.commit_sha=${CI_COMMIT_SHA}" --label "no.uninett.scm.pipeline_id=${CI_PIPELINE_ID}" --label "no.uninett.scm.project_url=${CI_PROJECT_URL}" "${BUILD_DIR:-.}"
18
    - docker push "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG"
19 20 21 22 23 24

.imagescan:
  extends: .docker
  image: registry.uninett.no/public/twistcli
  script:
    - gitlab-ci-scan
25 26

.kubernetes-deploy:
27
  image: registry.uninett.no/asm/kubernetes-deploy:v1.6
28

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
.production:
  extends: .kubernetes-deploy
  environment:
    name: production
    url: https://$KUBE_PROD_DOMAIN
  when: manual
  only:
    - master

.staging:
  extends: .kubernetes-deploy
  environment:
    name: staging
    url: https://$KUBE_TEST_ID-staging.paas2.uninett.no
  only:
    - master

46 47 48
.review:
  extends: .kubernetes-deploy
  environment:
49
    name: review/$CI_COMMIT_REF_NAME
50 51 52 53 54 55 56
    url: https://$KUBE_TEST_ID-$CI_ENVIRONMENT_SLUG.paas2.uninett.no
    on_stop: stop_review
  only:
    - branches
  except:
    - master

57
.stop:
58
  extends: .kubernetes-deploy
59
  dependencies: []
60 61 62 63
  script:
    - destroy
  environment:
    action: stop
64 65
  variables:
    GIT_STRATEGY: none
66
  when: manual
67 68 69 70 71

.stop_review:
  extends: .stop
  environment:
    name: review/$CI_COMMIT_REF_NAME
72 73 74 75
  only:
    - branches
  except:
    - master
76 77 78 79 80 81 82 83 84 85 86 87 88 89

.stop_production:
  extends: .stop
  environment:
    name: production
  only:
    - master

.stop_staging:
  extends: .stop
  environment:
    name: staging
  only:
    - master