forked from SonarSource/sonarlint-eclipse
/
build.sh
executable file
·126 lines (102 loc) · 4.44 KB
/
build.sh
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
124
125
126
#!/bin/bash
set -euo pipefail
CURRENT_VERSION=`mvn help:evaluate -Dtycho.mode=maven -Dexpression="project.version" | grep -v '^\[\|Download\w\+\:'`
RELEASE_VERSION=`echo $CURRENT_VERSION | sed "s/-.*//g"`
NEW_VERSION="$RELEASE_VERSION.$BUILD_ID"
echo "NEW_VERSION=$NEW_VERSION" >> build.properties
echo "Replacing version $CURRENT_VERSION with $NEW_VERSION"
mvn org.eclipse.tycho:tycho-versions-plugin:0.26.0:set-version -Dtycho.mode=maven -DnewVersion=$NEW_VERSION -B -e
export PROJECT_VERSION=$NEW_VERSION
if [ "${GITHUB_BRANCH}" == "master" ] && [ "$IS_PULLREQUEST" == "false" ]; then
echo '======= Build, deploy and analyze master'
# Fetch all commit history so that SonarQube has exact blame information
# for issue auto-assignment
# This command can fail with "fatal: --unshallow on a complete repository does not make sense"
# if there are not enough commits in the Git repository (even if Travis executed git clone --depth 50).
# For this reason errors are ignored with "|| true"
git fetch --unshallow || true
mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \
-Pdeploy-sonarsource,coverage,sign \
-Dsonarsource.keystore.path=$SONARSOURCE_KEYSTORE_PATH \
-Dsonarsource.keystore.password=$SONARSOURCE_KEYSTORE_PASS \
-Dtycho.disableP2Mirrors=true \
-Dmaven.test.redirectTestOutputToFile=false \
-B -e -V $*
REPO_URL="file://`pwd`/org.sonarlint.eclipse.site/target/repository/"
# Run ITs to collect IT coverage
cd its
mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify \
-Pcoverage \
-Dtycho.localArtifacts=ignore \
-Dtycho.disableP2Mirrors=true \
-Dsonarlint-eclipse.p2.url=$REPO_URL \
-B -e
cd ..
mvn sonar:sonar \
-Pcoverage \
-Dtycho.disableP2Mirrors=true \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.projectVersion=$CURRENT_VERSION \
-Dsonar.analysis.buildNumber=$BUILD_ID \
-Dsonar.analysis.pipeline=$BUILD_ID \
-Dsonar.analysis.sha1=$GIT_SHA1 \
-Dsonar.analysis.repository=$GITHUB_REPO \
-B -e -V $*
elif [ "$IS_PULLREQUEST" != "false" ] && [ -n "${GITHUB_TOKEN-}" ]; then
echo '======= Build and analyze pull request'
echo '======= with deploy'
# Fetch all commit history so that SonarQube has exact blame information
# for issue auto-assignment
# This command can fail with "fatal: --unshallow on a complete repository does not make sense"
# if there are not enough commits in the Git repository (even if Travis executed git clone --depth 50).
# For this reason errors are ignored with "|| true"
git fetch --unshallow || true
mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \
-Pdeploy-sonarsource,coverage \
-Dtycho.disableP2Mirrors=true \
-Dmaven.test.redirectTestOutputToFile=false \
-B -e -V $*
REPO_URL="file://`pwd`/org.sonarlint.eclipse.site/target/repository/"
# Run ITs to collect IT coverage
cd its
mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify \
-Pcoverage \
-Dtycho.localArtifacts=ignore \
-Dtycho.disableP2Mirrors=true \
-Dsonarlint-eclipse.p2.url=$REPO_URL \
-B -e
cd ..
mvn sonar:sonar \
-Pcoverage \
-Dtycho.disableP2Mirrors=true \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.pullrequest.branch=$GITHUB_BASE_BRANCH \
-Dsonar.pullrequest.base=$GITHUB_TARGET_BRANCH \
-Dsonar.pullrequest.key=$PULL_REQUEST \
-Dsonar.pullrequest.provider=github \
-Dsonar.pullrequest.github.repository=$GITHUB_REPO \
-Dsonar.analysis.buildNumber=$BUILD_ID \
-Dsonar.analysis.pipeline=$BUILD_ID \
-Dsonar.analysis.sha1=$GIT_SHA1 \
-Dsonar.analysis.repository=$GITHUB_REPO \
-Dsonar.analysis.prNumber=$PULL_REQUEST \
-B -e -V $*
elif [[ "${TRAVIS_BRANCH}" == "branch-"* ]] && [ "$IS_PULLREQUEST" == "false" ]; then
echo '======= Build, no analysis'
echo '======= with deploy'
mvn deploy \
-Pdeploy-sonarsource,sign \
-Dsonarsource.keystore.path=$SONARSOURCE_KEYSTORE_PATH \
-Dsonarsource.keystore.password=$SONARSOURCE_KEYSTORE_PASS \
-Dtycho.disableP2Mirrors=true \
-Dmaven.test.redirectTestOutputToFile=false \
-B -e -V $*
else
echo '======= Build, no analysis, no deploy'
mvn verify \
-Dmaven.test.redirectTestOutputToFile=false \
-Dtycho.disableP2Mirrors=true \
-B -e -V $*
fi