]> source.dussan.org Git - sonarqube.git/commitdiff
handle release distribution from travis
authorTom <thomas.verin@sonarsource.com>
Fri, 27 May 2016 13:34:03 +0000 (15:34 +0200)
committerTom <thomas.verin@sonarsource.com>
Fri, 27 May 2016 14:56:33 +0000 (16:56 +0200)
distribution.sh [new file with mode: 0755]
pom.xml
travis.sh

diff --git a/distribution.sh b/distribution.sh
new file mode 100755 (executable)
index 0000000..9679c3d
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+
+set -euo pipefail
+
+#
+# Evaluate a Maven expression
+#
+
+function maven_expression() {
+  mvn help:evaluate -Dexpression=$1 | grep -v '^\[\|Download\w\+\:'
+}
+
+ARTIFACTID="`maven_expression project.artifactId`"
+VERSION="`maven_expression project.version`"
+BINTRAY_REPO=Distribution
+BINTRAY_ACCOUNT=sonarsource
+
+if [[ "$VERSION" =~ "-build" ]] || [[ "$VERSION" =~ "-SNAPSHOT" ]]; then   
+  echo "This is a dev build, not releasing"
+  exit 0
+else
+  echo "About to release sonarqube"    
+fi
+
+cd sonar-application
+
+GROUPID="`maven_expression project.groupId`"
+ARTIFACTID="`maven_expression project.artifactId`"
+echo "$GROUPID $ARTIFACTID $VERSION"
+GROUPIDPATH=`echo $GROUPID | sed 's/\./\//g'`
+
+echo "Uploading sonarqube-$VERSION.zip to $BINTRAY_ACCOUNT/$BINTRAY_REPO"
+cd target 
+
+#zip file
+
+HTTP_CODE=`curl --write-out %{http_code} -T sonarqube-$VERSION.zip -u$BINTRAY_USER:$BINTRAY_TOKEN https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/SonarQube/$VERSION/sonarqube/`
+
+echo $HTTP_CODE
+
+if [[ "$HTTP_CODE" =~ "201" ]]; then   
+  echo "Uploaded to bintray"
+  echo "https://bintray.com/$BINTRAY_ACCOUNT/$BINTRAY_REPO/SonarQube/$VERSION/view#files"
+else
+  echo "Upload to bintray failed -> $HTTP_CODE"
+  exit -1
+fi
+
+#md5 file
+
+HTTP_CODE=`curl --write-out %{http_code} -T sonarqube-$VERSION.zip.md5 -u$BINTRAY_USER:$BINTRAY_TOKEN https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/SonarQube/$VERSION/sonarqube/`
+
+echo $HTTP_CODE
+
+if [[ "$HTTP_CODE" =~ "201" ]]; then   
+  echo "Uploaded to bintray"
+  echo "https://bintray.com/$BINTRAY_ACCOUNT/$BINTRAY_REPO/SonarQube/$VERSION/view#files"
+else
+  echo "Upload to bintray failed -> $HTTP_CODE"
+  exit -1
+fi
+
+#sha file
+
+HTTP_CODE=`curl --write-out %{http_code} -T sonarqube-$VERSION.zip.sha -u$BINTRAY_USER:$BINTRAY_TOKEN https://api.bintray.com/content/$BINTRAY_ACCOUNT/$BINTRAY_REPO/SonarQube/$VERSION/sonarqube/`
+
+echo $HTTP_CODE
+
+if [[ "$HTTP_CODE" =~ "201" ]]; then   
+  echo "Uploaded to bintray"
+  echo "https://bintray.com/$BINTRAY_ACCOUNT/$BINTRAY_REPO/SonarQube/$VERSION/view#files"
+else
+  echo "Upload to bintray failed -> $HTTP_CODE"
+  exit -1
+fi
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a31e5951ec7ef3c40336b46eca5741872d4dd39c..221fa371ee66b3836451edbc19cd24dc6076d47a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -87,6 +87,7 @@
 
     <!-- used for deployment to SonarSource Artifactory -->
     <gitRepositoryName>sonarqube</gitRepositoryName>
+    <artifactoryExclusion></artifactoryExclusion>
   </properties>
 
   <build>
       </properties>
     </profile>
     <profile>
-      <id>release</id>
+      <id>release</id>      
+      <properties>
+        <artifactoryExclusion>**/sonar-application*</artifactoryExclusion>
+      </properties>
       <build>
         <plugins>
           <plugin>
         <module>tests</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>${version.artifactory.plugin}</version>
+            <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>
+                    <excludePatterns>${artifactoryExclusion}</excludePatterns>
+                    <filterExcludedArtifactsFromBuild>true</filterExcludedArtifactsFromBuild>
+                  </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>
index 9859d8a5f3cf5219371875d3689c0cff17ded597..50e6da7b3cf1593071288255424bb45b5d5ede16 100755 (executable)
--- a/travis.sh
+++ b/travis.sh
@@ -38,14 +38,22 @@ CI)
       echo "======= Found SNAPSHOT version ======="
       # Do not deploy a SNAPSHOT version but the release version related to this build
       set_maven_build_version $TRAVIS_BUILD_NUMBER
+      # analysis is currently executed by SonarSource internal infrastructure
+      mvn deploy \
+          -Pdeploy-sonarsource \
+          -B -e -V 
     else
       echo "======= Found RELEASE version ======="
+      # analysis is currently executed by SonarSource internal infrastructure
+      mvn deploy \
+          -Dmaven.test.skip=true \
+          -Pdeploy-sonarsource,release \
+          -B -e -V
+      ./distribution.sh
+
     fi
 
-    # analysis is currently executed by SonarSource internal infrastructure
-    mvn deploy \
-        -Pdeploy-sonarsource,release \
-        -B -e -V 
+    
 
   elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
     strongEcho 'Build and analyze pull request, no deploy'