-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
87 lines (77 loc) · 2.74 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
stages:
- build
- test
- report
- deploy
variables:
MAVEN_OPTS:
-Dmaven.repo.local=.m2/repository
-Dhttps.protocols=TLSv1.2
-Djava.awt.headless=true
build image:
stage: build
rules:
- changes:
- Dockerfile
# - .gitlab-ci.yml
image:
name: gcr.io/kaniko-project/executor:v1.9.0-debug
entrypoint: ['']
script:
- /kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CI_REGISTRY_IMAGE/image:main
--cache=true --cache-repo $CI_REGISTRY_IMAGE
--build-arg http_proxy=$http_proxy
--build-arg https_proxy=$https_proxy
--build-arg no_proxy=$no_proxy
test:
stage: test
image: maven:3.8.6-jdk-11
script:
- echo "Running some tests"
- echo "${CI_JOB_ID}" > jobid
- mvn test
after_script:
- cp -r $CI_PROJECT_DIR/target/allure-results $CI_PROJECT_DIR/allure-results
artifacts:
when: always
expire_in: 2 hours
paths:
- allure-results
- jobid
allow_failure: true
report:
stage: report
image: registry.gitlab.com/gkalian/gitlab-allure-history-java/image:main
script:
- git clone --single-branch --branch gl-pages https://${GL_TOKEN}:${GL_TOKEN_VALUE}@gitlab.com/gkalian/gitlab-allure-history-java.git
- JOB_ID=$(cat jobid)
- REPORT=job_${JOB_ID}
- CURRENT_BRANCH=${CI_PROJECT_NAME}/public/${CI_COMMIT_REF_NAME}
- cp -r ./${CURRENT_BRANCH}/history allure-results || echo "No history"
- echo '{"name":"GitLabCI","type":"gitlab","reportName":"Allure Report with history",' > executor.json
- echo "\"reportUrl\":\"${CI_PAGES_URL}/${CI_COMMIT_REF_NAME}/${REPORT}/\"," >> executor.json
- echo "\"buildUrl\":\"${CI_PIPELINE_URL}\"," >> executor.json
- echo "\"buildName\":\"GitLab Job Run ${JOB_ID}\",\"buildOrder\":\"${JOB_ID}\"}" >> executor.json
- mv ./executor.json ./allure-results
- /home/allure-cmd/bin/allure generate allure-results -o $REPORT
- mkdir -p $CURRENT_BRANCH
- cp -r $REPORT $CURRENT_BRANCH
- cp -r ${REPORT}/history $CURRENT_BRANCH
- cp -r generate_index.groovy $CI_PROJECT_NAME
- cd $CI_PROJECT_NAME
- /home/groovy/bin/groovy generate_index.groovy public
- /home/groovy/bin/groovy generate_index.groovy public/${CI_COMMIT_REF_NAME}
- git config user.name "Gitlab Runner"
- git config user.email ${GITLAB_USER_EMAIL}
- >
git remote add $CI_PROJECT_NAME
https://oauth2:${ALLURE_GITLAB_PAGES}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
- git status -s
- git add ./public/
- git commit -m "pipeline_${CI_PIPELINE_ID}_job_${CI_JOB_ID}"
- git push -u https://${GL_TOKEN}:${GL_TOKEN_VALUE}@gitlab.com/gkalian/gitlab-allure-history-java.git
needs:
- test