-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.yml
85 lines (76 loc) · 2.72 KB
/
config.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
version: 2.1
orbs:
maven: circleci/[email protected]
jobs:
master_push_job:
working_directory: ~/ing-sw-2020-Riva-Sanvito-Truong
docker:
- image: circleci/openjdk:14-jdk-buster
steps:
- checkout
- run:
name: Configure git user
command: |
git config user.email "[email protected]"
git config user.name "ci-build"
- add_ssh_keys:
fingerprints:
- "85:53:74:17:3d:df:9e:92:91:97:95:3e:96:09:c5:ec"
- run:
name: Prepare Maven settings
command: |
mkdir ~/.m2/
cp .circleci/mvn-settings.xml ~/.m2/settings.xml
- restore_cache: # restore the saved cache after the first run or if `pom.xml` has changed
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
key: circleci-v2-{{ checksum "pom.xml" }}
- run:
name: Run tests and build
command: mvn clean install
- save_cache: # saves the project dependencies
paths:
- ~/.m2
key: circleci-v2-{{ checksum "pom.xml" }}
- run:
name: Run SonarQube if [sonar] is present in the commit title
command: |
set +e
set +o pipefail
last_commit="$(git log -1 --pretty=%B | cat | grep sonar)"
if [[ ${last_commit} == *[sonar]* ]]; then
mvn sonar:sonar "-Dsonar.login=${SONARQUBE_TOKEN}"
else
echo "[sonar] keyword missing from commit title; skipping SonarQube run."
fi
- run:
name: Generate javadoc
command: |
javadoc \
-classpath "$(find ~/.m2/repository -name '*.jar' | tr '\n' ':')" \
-sourcepath src/main/java \
-d docs/javadoc \
-private \
-subpackages \
it.polimi.ingsw
- store_artifacts:
path: docs/javadoc
- run:
name: Commit new artifacts path
command: |
cat \<<EOF > docs/javadoc/README.md
# javadocs
Head to the latest [CircleCI build artifacts](https://${CIRCLE_BUILD_NUM}-244441529-gh.circle-artifacts.com/0/docs/javadoc/index.html) to access the javadoc for the project.
N.B.: you need to be [authenticated to CircleCI](https://circleci.com/vcs-authorize/) in order to access the build artifacts.
EOF
git add docs/javadoc/*
git commit -m "docs(javadoc): update javadoc [skip ci]"
git push --set-upstream origin ${CIRCLE_BRANCH}
workflows:
version: 2
master_push:
jobs:
- master_push_job:
filters:
branches:
only:
- master