-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
61 lines (51 loc) · 2.31 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
.openshift_auth_setup: &openshift_auth_setup
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
before_script:
- echo "Sourcing SCM branch environment at modules/web-ui/deployment/cern-oc/${CI_COMMIT_REF_NAME}.env"
- source modules/web-ui/deployment/cern-oc/deployment/${CI_COMMIT_REF_NAME}.env
- export ENV_FILE_VAR="${CI_COMMIT_REF_NAME^^}_ENV"
- echo "Sourcing ${ENV_FILE_VAR} into .env file "
- cat ${!ENV_FILE_VAR} > .env
- source .env
- echo "Authenticating with ${OPENSHIFT_SERVER}"
- oc login $OPENSHIFT_SERVER --token=$OPENSHIFT_TOKEN
- oc project $NAMESPACE
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
only:
- develop
- master
Build Web UI image:
stage: build
image:
name: gitlab-registry.cern.ch/ci-tools/docker-image-builder
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- echo Building latest Docker Image $CI_REGISTRY_IMAGE/web-ui:$CI_COMMIT_REF_NAME
- /kaniko/executor --context $CI_PROJECT_DIR/modules/web-ui --dockerfile $CI_PROJECT_DIR/modules/web-ui/Dockerfile --destination $CI_REGISTRY_IMAGE/web-ui:$CI_COMMIT_REF_NAME
only:
refs: [master, develop]
Update deployment:
<<: *openshift_auth_setup
stage: deploy
script:
- echo "***** Updating instance deployment for ${CI_COMMIT_REF_NAME}"
- oc process --ignore-unknown-parameters -o json --param-file=deployment/${CI_COMMIT_REF_NAME}.env -f modules/web-ui/deployment/cern-oc/service.yml --local=true | jq '.items[] | select (.kind != "PersistentVolumeClaim")' | oc apply -f -
- oc process --ignore-unknown-parameters --param-file=deployment/${CI_COMMIT_REF_NAME}.env -f modules/web-ui/deployment/cern-oc/routes.yml --local=true | oc apply -f -
only:
refs: [develop, master]
changes:
- "modules/web-ui/deployment/cern-oc/**/*"