-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
123 lines (112 loc) · 3.63 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
116
117
118
119
120
121
122
123
image: dockerhub.dsi.tecnico.ulisboa.pt/fenix-framework/docker/java-fenix-framework:jdk8-node16
cache:
paths:
- .m2/repository/
- target/
- openapi/node_modules/
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
# Avoid duplicate pipelines on merge requests
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- when: always
stages:
- Install and Lint
# - Test
- Deploy Pages
- Release
- Notify
Install:
stage: Install and Lint
before_script:
- cp -R /opt/config_m2/. $CI_PROJECT_DIR/.m2
- export MAVEN_REPO_USER=$NEXUS_USERNAME
- export MAVEN_REPO_PASS=$NEXUS_PASSWORD
- export MAVEN_REPO_ID=dsi-maven-artifacts
script:
- mvn -s $CI_PROJECT_DIR/.m2/settings.xml clean install -Dmaven.test.skip=true
Lint:
stage: Install and Lint
before_script:
- cp -R /opt/config_m2/. $CI_PROJECT_DIR/.m2
- export MAVEN_REPO_USER=$NEXUS_USERNAME
- export MAVEN_REPO_PASS=$NEXUS_PASSWORD
- export MAVEN_REPO_ID=dsi-maven-artifacts
script:
- mvn -s $CI_PROJECT_DIR/.m2/settings.xml clean formatter:validate -Dmaven.test.skip=true
Validate OpenAPI Schema:
stage: Install and Lint
script:
- cd $CI_PROJECT_DIR/openapi
- npm ci
- npm run validate
# Test:
# stage: Test
# script:
# - mvn test
Release:
stage: Release
before_script:
- cp -R /opt/config_m2/. $CI_PROJECT_DIR/.m2
- export MAVEN_REPO_USER=$NEXUS_USERNAME
- export MAVEN_REPO_PASS=$NEXUS_PASSWORD
- export MAVEN_REPO_ID=dsi-maven-artifacts
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@repo.dsi.tecnico.ulisboa.pt/tools/release-army-knife.git
- cd release-army-knife
- npm install
- cd ..
- mvn help:evaluate
- VERSION=$(echo '${project.version}' | mvn help:evaluate | grep -v '^[[]')
- if [[ v$VERSION != $CI_COMMIT_TAG ]]; then echo "Version v$VERSION in pom.xml diferent from $CI_COMMIT_TAG tag" && exit 1; fi
script:
- mvn -s $CI_PROJECT_DIR/.m2/settings.xml --batch-mode deploy -Dmaven.test.skip=true
- node release-army-knife/release.js $CI_PROJECT_ID $CI_COMMIT_TAG $REPO_API_ACCESS_TOKEN
only:
- tags
Notify:
stage: Notify
before_script:
- cp -R /opt/config_m2/. $CI_PROJECT_DIR/.m2
- export MAVEN_REPO_USER=$NEXUS_USERNAME
- export MAVEN_REPO_PASS=$NEXUS_PASSWORD
- export MAVEN_REPO_ID=dsi-maven-artifacts
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@repo.dsi.tecnico.ulisboa.pt/tools/release-army-knife.git
- cd release-army-knife
- npm install
- cd ..
- mvn help:evaluate
- VERSION=$(echo '${project.version}' | mvn help:evaluate | grep -v '^[[]')
- if [[ v$VERSION != $CI_COMMIT_TAG ]]; then echo "Version v$VERSION in pom.xml diferent from $CI_COMMIT_TAG tag" && exit 1; fi
script:
- node release-army-knife/notify-mattermost.js $CI_PROJECT_ID $CI_COMMIT_TAG $REPO_API_ACCESS_TOKEN $CHAT_HOOK
only:
- tags
pages:
stage: Deploy Pages
cache:
paths:
- website/node_modules/
script:
- cd website
- npm ci
- npm run build
- cd ..
- cp -r website/public public/
# Optional: this gzips all files, so GitLab can serve compressed assets.
- gzip -k -6 $(find public -type f)
artifacts:
paths:
- public/
rules:
# Only publish to pages automatically when a tag is created.
# Changing the website between tags requires manual action, to avoid
# publishing documentation that is not yet in production.
- if: $CI_COMMIT_TAG
when: on_success
- changes:
- website/**/*
when: manual
allow_failure: true # allow pipeline to success even if this isn't triggered
- when: never