You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/05/30 07:55:39 UTC

[GitHub] sijie closed pull request #1454: Allow CI to publish a snapshot version with gitsha information

sijie closed pull request #1454: Allow CI to publish a snapshot version with gitsha information
URL: https://github.com/apache/bookkeeper/pull/1454
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy b/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy
index 1a045d460..3b66ca8b0 100644
--- a/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy
+++ b/.test-infra/jenkins/job_bookkeeper_release_nightly_snapshot.groovy
@@ -37,7 +37,28 @@ freeStyleJob('bookkeeper_release_nightly_snapshot') {
       'Release Snapshot',
       '/release-snapshot')
 
+  parameters {
+      stringParam(
+          'sha1',
+          defaultBranch,
+          'Commit id or refname (eg: origin/pr/9/head) you want to build.')
+        
+      stringParam(
+          'PUBLISH_GITSHA',
+          'false',
+          'Whether to publish a snapshot with gitsha information. Options: (true|false).')
+  }
+
   steps {
+    // update snapshot version if `PUBLISH_GITSHA` is `true`
+    shell '''
+export MAVEN_HOME=/home/jenkins/tools/maven/latest
+export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
+export MAVEN_OPTS=-Xmx2048m
+
+./dev/update-snapshot-version.sh
+    '''.stripIndent().trim()
+
     maven {
       // Set maven parameters.
       common_job_properties.setMavenConfig(delegate)
diff --git a/dev/common.sh b/dev/common.sh
index fb4be7435..d4f3d3f2e 100644
--- a/dev/common.sh
+++ b/dev/common.sh
@@ -29,6 +29,13 @@ function get_bk_version() {
     echo ${bk_version}
 }
 
+function get_snapshot_version_with_gitsha() {
+    local gitsha=$(git rev-parse --short HEAD)
+    local commitdate=$(git log -1 --date=format:'%Y%m%d' --pretty=format:%cd)
+    local version=$(get_bk_version)
+    echo ${version/-SNAPSHOT/}-${commitdate}-${gitsha}-SNAPSHOT
+}
+
 export BK_DEV_DIR=`dirname "$0"`
 export BK_HOME=`cd ${BK_DEV_DIR}/..;pwd`
 export BK_VERSION=`get_bk_version`
diff --git a/dev/update-snapshot-version.sh b/dev/update-snapshot-version.sh
new file mode 100755
index 000000000..59adf078b
--- /dev/null
+++ b/dev/update-snapshot-version.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+#
+# vim:et:ft=sh:sts=2:sw=2
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+###############################################################################
+# Script to update the maven project version to a snapshot version with gitsha
+# before publishing snapshot versions.
+#
+# usage: ./dev/update-snapshot-version.sh
+
+source `dirname "$0"`/common.sh
+
+OLD_VERSION=$(get_bk_version)
+if [ "x${PUBLISH_GITSHA}" = "xtrue" ]; then
+    NEW_VERSION=$(get_snapshot_version_with_gitsha)
+    echo "Update version from ${OLD_VERSION} to ${NEW_VERSION}"
+
+    mvn versions:set -Dstream -DnewVersion=${NEW_VERSION} 
+    mvn versions:commit -Dstream
+fi


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services