-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
72 lines (66 loc) · 1.58 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
61
62
63
64
65
66
67
68
69
70
71
72
.prep_go: &prep_go
before_script:
- export GL_URL=$(echo $CI_PROJECT_URL | awk -F/ '{print $3}')
- export GO_PROJECT_PATH="$GOPATH/src/github.com/erraa/"
- mkdir -p $GO_PROJECT_PATH
- ln -s $(pwd) $GO_PROJECT_PATH
- export GO_PROJECT_PATH="$GO_PROJECT_PATH/$CI_PROJECT_NAME"
- cd $GO_PROJECT_PATH
variables:
IMAGE_TAG: erraa/aciexporter:latest
stages:
- build
- test
- docker_build
- deploy
- cleanup
go_build:
<<: *prep_go
stage: build
image: golang:1.11
tags:
- aci
script:
- go get ./...
- go build
go_test:
<<: *prep_go
stage: test
image: golang:1.11
tags:
- aci
script:
- go get ./...
- go test ./...
docker_build:
stage: docker_build
before_script:
- docker login -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
tags:
- docker
script:
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
only:
- master
deploy:
stage: deploy
before_script:
- docker login -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
tags:
- docker
script:
- docker rm aciexporter --force
- docker run --restart unless-stopped -d -v /home/prometheus/aciexporter.yaml:/root/aciexporter.yaml -p 8383:8383 --name aciexporter erraa/aciexporter:latest
- docker network connect prom-net aciexporter
only:
- master
cleanup:
stage: cleanup
tags:
- docker
script:
- docker rmi $(docker images --filter=dangling=true -q)
when: always
only:
- master