-
Notifications
You must be signed in to change notification settings - Fork 44
/
.gitlab-ci.yml
115 lines (106 loc) · 3.22 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#######################################
### sfdx-hardis monitoring pipeline ###
#######################################
# Doc & support: https://sfdx-hardis.cloudity.com/salesforce-monitoring-home/
# PLEASE DO NOT UPDATE THIS FILE EXCEPT TO ADD TAGS TO YOUR STEPS
variables:
FORCE_COLOR: "1"
# Pipeline stages
stages:
- backup
- monitor
# Use sfdx-hardis docker image to always be up to date with latest version
image: hardisgroupcom/sfdx-hardis:latest # test with alpha
##############################################
### Sfdx Sources Backup + Push new commit ####
##############################################
backup:
stage: backup
interruptible: true
#tags:
# - ubuntu
before_script:
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
script:
# Extract metadata folders (+other checks ^^)
- sfdx hardis:auth:login
- sfdx hardis:org:monitor:backup
# Commit and push new state
- git status
- git add --all
- git commit -m "Org state on $(date -u +'%Y-%m-%d %H:%M') for $CI_COMMIT_REF_NAME [skip ci]" || echo "No changes to commit"
- git push -o ci-skip https://root:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME
artifacts:
when: always
paths:
- hardis-report
expire_in: 6 month
######################
### Run Apex Tests ###
######################
apex_tests:
stage: monitor
interruptible: true
allow_failure: true
#tags:
# - ubuntu
before_script:
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git pull origin "${CI_COMMIT_REF_NAME}"
script:
# Login & run apex tests
- sfdx hardis:auth:login
- sfdx hardis:org:test:apex
artifacts:
when: always
paths:
- hardis-report
expire_in: 6 month
# Monitoring tools
monitoring_tools:
stage: monitor
interruptible: true
allow_failure: true
#tags:
# - ubuntu
before_script:
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git pull origin "${CI_COMMIT_REF_NAME}"
script:
# Login & run apex tests
- sfdx hardis:auth:login
- sfdx hardis:org:monitor:all
artifacts:
when: always
paths:
- hardis-report
expire_in: 6 month
############################################################
### Run MegaLinter to detect quality and security issues ###
############################################################
megalinter:
stage: monitor
interruptible: true
allow_failure: true
#tags:
# - ubuntu
image: oxsecurity/megalinter-salesforce:latest
script: ["true"]
before_script:
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git pull origin "${CI_COMMIT_REF_NAME}"
variables:
# All available variables are described in documentation
# https://megalinter.io/latest/config-file/
DEFAULT_WORKSPACE: $CI_PROJECT_DIR
DEFAULT_BRANCH: master
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
artifacts:
when: always
paths:
- megalinter-reports
expire_in: 6 month