-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy path.gitlab-ci.yml
85 lines (75 loc) · 2 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
73
74
75
76
77
78
79
80
81
82
83
84
85
---
variables:
# CI_DEBUG_TRACE: "true"
GITLAB_TOKEN: $GITLAB_TOKEN # https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html
GITLAB_FQDN: $GITLAB_FQDN # You instanse FQDN, e.g. https://gitlab.com or https://gitlab.example.com
ZABBIX_USERNAME: $ZBX_USER # Zabbix user with admin privilege
ZABBIX_PASSWORD: $ZBX_PASSWORD
GITLAB_GROUP: $GITLAB_GROUP
NEW_ZABBIX_URL: $NEW_ZABBIX_URL
NEW_YAML_REPO: $NEW_YAML_REPO
NEW_XML_REPO: $NEW_XML_REPO
USER_EMAIL: $USER_EMAIL
USER_NAME: $USER_NAME
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
cache:
paths:
- "$CI_PROJECT_DIR/pip-cache"
key: "$CI_PROJECT_ID"
before_script:
- date
after_script:
- date
.review: &review
tags:
- zabbix
script:
- python3 -m pip install --user -r requirements.txt
- git config --global user.email "$USER_EMAIL"
- git config --global user.name "$USER_NAME"
- git clone https://oauth2:$GITLAB_TOKEN@$GITLAB_FQDN/$GITLAB_GROUP/$GITLAB_REPO.git
- cd $GITLAB_REPO
- git checkout -b develop origin/develop || git checkout develop
- git pull
- rm -rf *
- python3 ../zabbix-export.py $SAVE_YAML
- git add .
- d=$(date +%Y-%m-%d)
- "git commit -m':robot: Autobackup' ||:"
- git push origin develop
.review-manual: &review-manual
<<: *review
when: manual
.review-schedules: &review-schedules
<<: *review
only:
- schedules
#
# You job for review and backup
#
# Example for you instance
YAML new zabbix:
variables:
GITLAB_REPO: $NEW_YAML_REPO
ZABBIX_URL: $NEW_ZABBIX_URL
SAVE_YAML: --save-yaml
<<: *review-manual
YAML SCHEDULE new zabbix:
variables:
GITLAB_REPO: $NEW_YAML_REPO
ZABBIX_URL: $NEW_ZABBIX_URL
SAVE_YAML: --save-yaml
<<: *review-schedules
XML new zabbix:
variables:
GITLAB_REPO: $NEW_XML_REPO
ZABBIX_URL: $NEW_ZABBIX_URL
SAVE_YAML: ""
<<: *review-manual
# XML SCHEDULE new zabbix:
# variables:
# GITLAB_REPO: $NEW_XML_REPO
# ZABBIX_URL: $NEW_ZABBIX_URL
# SAVE_YAML: ""
# <<: *review-schedules
...