@@ -33,3 +33,5 @@ before_cache: | |||
notifications: | |||
email: false | |||
webhooks: | |||
- secure: "UsCLBZ1wEQkEPhlIETa8127r+/e+p0NFQR2f6XxvpDdyogQsgsmdz5nOjdttrWItbNNPGyZu+d/W6a/BckpS+hZBgbGbnwKe2Ht6VVIWvhDgcyXpM19CQqfXQVaGpnLTDwXy4ajases1aqsvGaUrljII74phkij/AhnIURxH/FY=" |
@@ -82,6 +82,9 @@ | |||
<argLine>-Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=160m</argLine> | |||
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile> | |||
<!-- used for deployment to SonarSource Artifactory --> | |||
<gitRepositoryName>sonarqube</gitRepositoryName> | |||
</properties> | |||
<build> | |||
@@ -1484,13 +1487,6 @@ | |||
</build> | |||
</profile> | |||
<profile> | |||
<id>analysis</id> | |||
<properties> | |||
<coveragePerTest>true</coveragePerTest> | |||
</properties> | |||
</profile> | |||
<profile> | |||
<!-- integration tests --> | |||
<id>it</id> | |||
@@ -1498,6 +1494,99 @@ | |||
<module>it</module> | |||
</modules> | |||
</profile> | |||
<profile> | |||
<id>deploy-sonarsource</id> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-enforcer-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<id>enforce-deploy-settings</id> | |||
<goals> | |||
<goal>enforce</goal> | |||
</goals> | |||
<configuration> | |||
<rules> | |||
<requireProperty> | |||
<property>gitRepositoryName</property> | |||
<message>You must set name of Git repository in your pom</message> | |||
</requireProperty> | |||
<requireEnvironmentVariable> | |||
<variableName>ARTIFACTORY_URL</variableName> | |||
</requireEnvironmentVariable> | |||
<requireEnvironmentVariable> | |||
<variableName>ARTIFACTORY_DEPLOY_REPO</variableName> | |||
</requireEnvironmentVariable> | |||
<requireEnvironmentVariable> | |||
<variableName>ARTIFACTORY_DEPLOY_USERNAME</variableName> | |||
</requireEnvironmentVariable> | |||
<requireEnvironmentVariable> | |||
<variableName>ARTIFACTORY_DEPLOY_PASSWORD</variableName> | |||
</requireEnvironmentVariable> | |||
</rules> | |||
<fail>true</fail> | |||
</configuration> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
<plugin> | |||
<!-- this maven plugin is not deployed in Maven Central. It should be downloaded | |||
from JFrog JCenter or from SonarSource repositories --> | |||
<groupId>org.jfrog.buildinfo</groupId> | |||
<artifactId>artifactory-maven-plugin</artifactId> | |||
<version>2.4.0</version> | |||
<inherited>false</inherited> | |||
<executions> | |||
<execution> | |||
<id>build-info</id> | |||
<goals> | |||
<goal>publish</goal> | |||
</goals> | |||
<configuration> | |||
<artifactory> | |||
<envVarsExcludePatterns> | |||
*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login* | |||
</envVarsExcludePatterns> | |||
<includeEnvVars>true</includeEnvVars> | |||
<timeoutSec>60</timeoutSec> | |||
</artifactory> | |||
<deployProperties> | |||
<vcs.revision>{{GIT_COMMIT|TRAVIS_COMMIT}}</vcs.revision> | |||
<vcs.branch>{{GIT_BRANCH|TRAVIS_BRANCH}}</vcs.branch> | |||
<build.name>${gitRepositoryName}</build.name> | |||
<build.number>{{BUILD_ID|TRAVIS_BUILD_NUMBER}}</build.number> | |||
</deployProperties> | |||
<licenses> | |||
<autoDiscover>true</autoDiscover> | |||
<includePublishedArtifacts>false</includePublishedArtifacts> | |||
<runChecks>true</runChecks> | |||
<scopes>project,provided</scopes> | |||
<violationRecipients>licences-control@sonarsource.com</violationRecipients> | |||
</licenses> | |||
<publisher> | |||
<contextUrl>${env.ARTIFACTORY_URL}</contextUrl> | |||
<repoKey>${env.ARTIFACTORY_DEPLOY_REPO}</repoKey> | |||
<username>${env.ARTIFACTORY_DEPLOY_USERNAME}</username> | |||
<password>${env.ARTIFACTORY_DEPLOY_PASSWORD}</password> | |||
<publishBuildInfo>true</publishBuildInfo> | |||
<publishArtifacts>true</publishArtifacts> | |||
</publisher> | |||
<buildInfo> | |||
<buildName>${gitRepositoryName}</buildName> | |||
<buildNumber>{{BUILD_ID|TRAVIS_BUILD_NUMBER}}</buildNumber> | |||
<buildUrl>{{CI_BUILD_URL|BUILD_URL}}</buildUrl> | |||
<vcsRevision>{{GIT_COMMIT|TRAVIS_COMMIT}}</vcsRevision> | |||
</buildInfo> | |||
</configuration> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</profile> | |||
</profiles> | |||
</project> |
@@ -2,11 +2,12 @@ | |||
set -euo pipefail | |||
function installTravisTools { | |||
function configureTravis { | |||
mkdir ~/.local | |||
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v21 | tar zx --strip-components 1 -C ~/.local | |||
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v23 | tar zx --strip-components 1 -C ~/.local | |||
source ~/.local/bin/install | |||
} | |||
configureTravis | |||
function strongEcho { | |||
echo "" | |||
@@ -16,45 +17,54 @@ function strongEcho { | |||
case "$TARGET" in | |||
CI) | |||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "${TRAVIS_BRANCH}" == "master" ] && [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]; then | |||
# For security reasons environment variables are not available on the pull requests | |||
# coming from outside repositories | |||
# http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests | |||
strongEcho 'Build and analyze pull request' | |||
# this pull request must be built and analyzed (without upload of report) | |||
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar \ | |||
-Panalysis \ | |||
-Dclirr=true \ | |||
-Dsonar.analysis.mode=issues \ | |||
-Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \ | |||
-Dsonar.github.repository=$TRAVIS_REPO_SLUG \ | |||
-Dsonar.github.oauth=$GITHUB_TOKEN \ | |||
-Dsonar.host.url=$SONAR_HOST_URL \ | |||
-Dsonar.login=$SONAR_TOKEN \ | |||
-B -e -V -U | |||
if [ "${TRAVIS_BRANCH}" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then | |||
strongEcho 'Build and deploy' | |||
# Do not deploy a SNAPSHOT version but the release version related to this build | |||
set_maven_build_version $TRAVIS_BUILD_NUMBER | |||
mvn deploy \ | |||
-Pdeploy-sonarsource \ | |||
-Dmaven.test.redirectTestOutputToFile=false \ | |||
-B -e -V | |||
elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN-}" ]; then | |||
strongEcho 'Build and analyze pull request, no deploy' | |||
# No need for Maven phase "install" as the generated JAR file does not need to be installed | |||
# in Maven local repository. Phase "verify" is enough. | |||
mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar \ | |||
-Pcoverage-per-test \ | |||
-Dclirr=true \ | |||
-Dmaven.test.redirectTestOutputToFile=false \ | |||
-Dsonar.analysis.mode=issues \ | |||
-Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \ | |||
-Dsonar.github.repository=$TRAVIS_REPO_SLUG \ | |||
-Dsonar.github.oauth=$GITHUB_TOKEN \ | |||
-Dsonar.host.url=$SONAR_HOST_URL \ | |||
-Dsonar.login=$SONAR_TOKEN \ | |||
-B -e -V | |||
else | |||
strongEcho 'Build, no analysis' | |||
# Build branch, without any analysis | |||
strongEcho 'Build, no analysis, no deploy' | |||
# No need for Maven goal "install" as the generated JAR file does not need to be installed | |||
# in Maven local repository | |||
mvn verify -B -e -V | |||
# No need for Maven phase "install" as the generated JAR file does not need to be installed | |||
# in Maven local repository. Phase "verify" is enough. | |||
mvn verify \ | |||
-Dmaven.test.redirectTestOutputToFile=false \ | |||
-B -e -V | |||
fi | |||
;; | |||
POSTGRES) | |||
installTravisTools | |||
psql -c 'create database sonar;' -U postgres | |||
runDatabaseCI "postgresql" "jdbc:postgresql://localhost/sonar" "postgres" "" | |||
;; | |||
MYSQL) | |||
installTravisTools | |||
mysql -e "CREATE DATABASE sonar CHARACTER SET UTF8;" -uroot | |||
mysql -e "CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';" -uroot | |||
mysql -e "GRANT ALL ON sonar.* TO 'sonar'@'localhost';" -uroot | |||
@@ -74,8 +84,6 @@ IT) | |||
if [ "$IT_CATEGORY" == "Plugins" ] && [ ! -n "$GITHUB_TOKEN" ]; then | |||
echo "This job is ignored as it needs to access a private GitHub repository" | |||
else | |||
installTravisTools | |||
start_xvfb | |||
mvn install -Pit,dev -DskipTests -Dcategory=$IT_CATEGORY -Dmaven.test.redirectTestOutputToFile=false -e -Dsource.skip=true |