You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ka...@apache.org on 2017/11/09 19:11:13 UTC

mesos git commit: Added bintray publishing scripts.

Repository: mesos
Updated Branches:
  refs/heads/master 844590611 -> 1132e1dda


Added bintray publishing scripts.

Review: https://reviews.apache.org/r/63543


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1132e1dd
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1132e1dd
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1132e1dd

Branch: refs/heads/master
Commit: 1132e1ddafa6a1a9bc8aa966bd01d7b35c7682d9
Parents: 8445906
Author: Kapil Arya <ka...@mesosphere.io>
Authored: Fri Nov 3 10:37:32 2017 -0400
Committer: Kapil Arya <ka...@mesosphere.io>
Committed: Thu Nov 9 14:10:12 2017 -0500

----------------------------------------------------------------------
 support/packaging/Jenkinsfile         | 34 ++++++++++--
 support/packaging/bintray.sh          | 83 ++++++++++++++++++++++++++++++
 support/packaging/centos/build_rpm.sh |  7 ++-
 3 files changed, 119 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1132e1dd/support/packaging/Jenkinsfile
----------------------------------------------------------------------
diff --git a/support/packaging/Jenkinsfile b/support/packaging/Jenkinsfile
index abfd59d..7446b2b 100644
--- a/support/packaging/Jenkinsfile
+++ b/support/packaging/Jenkinsfile
@@ -2,14 +2,42 @@ def dockerArgs() {
   def workspace_dir = pwd()
   sh "mkdir -p ${workspace_dir}/.m2"
 
-  def args = "-e MESOS_TAG=${params.MESOS_TAG}"
+  def args = ""
+      args = "${args} -e MESOS_TAG=${params.MESOS_TAG}"
       args = "${args} -e MESOS_RELEASE=${params.MESOS_RELEASE}"
+
+      // Jenkins runs docker containers with the current user and group
+      // ('-u$(id -u):$(id -g)'). Here we map /etc/{passwd,group} inside the
+      // container so that the rpm/deb files will be created with the correct
+      // uid/gid.
       args = "${args} -v=/etc/passwd:/etc/passwd"
       args = "${args} -v=/etc/group:/etc/group"
+
+      // Jenkins maps the current working directory into the container using
+      // '-v=$PWD:$PWD,rw,z'. As a result the $HOME directory is also mapped as
+      // $HOME in the container, but without any write permissions. Thus, when
+      // Maven tries to use $HOME/.m2 for downloading dependencies, it fails.
+      // The following volume mount solves this by explicitly mounting $HOME/.m2
+      // inside the container.
       args = "${args} -v=${workspace_dir}/.m2:$HOME/.m2:rw,z"
   return args
 }
 
+def uploadToBintray(def pattern) {
+  withCredentials([string(credentialsId: 'karya_bintray_credentials', variable: 'BINTRAY_CREDS')]) {
+    // Do not upload debug packages yet as they are larger than the max file
+    // upload size imposed by bintray for the mesos org (250 MB). Once the mesos
+    // repos are moved under the apache org, we'll probably be able to upload
+    // larger files. An alternative would be to split mesos package into smaller
+    // packages such as mesos-sched, mesos-modules, etc., and then have the
+    // mesos meta package declare a dependency on these sub packages. That way
+    // we can have much smaller debug files.
+    sh 'find . -name ' + pattern ' | ' +
+       'grep -v debug | ' +
+       'while read rpm ; do support/packaging/bintray.sh $rpm; done'
+  }
+}
+
 parallel(centos7: {
   node {
     checkout scm
@@ -23,11 +51,11 @@ parallel(centos7: {
     }
 
     img.inside(dockerArgs()) {
-      sh 'hostname && hostname && cat /etc/*rel* || true'
       sh 'support/packaging/centos/build_rpm.sh'
     }
 
     archiveArtifacts artifacts: '**/*.rpm', fingerprint: true
+    uploadToBintray('*.rpm')
   }
 },
 centos6: {
@@ -43,10 +71,10 @@ centos6: {
     }
 
     img.inside(dockerArgs()) {
-      sh 'hostname && hostname && cat /etc/*rel* || true'
       sh 'support/packaging/centos/build_rpm.sh'
     }
 
     archiveArtifacts artifacts: '**/*.rpm', fingerprint: true
+    uploadToBintray('*.rpm')
   }
 })

http://git-wip-us.apache.org/repos/asf/mesos/blob/1132e1dd/support/packaging/bintray.sh
----------------------------------------------------------------------
diff --git a/support/packaging/bintray.sh b/support/packaging/bintray.sh
new file mode 100755
index 0000000..4f1795f
--- /dev/null
+++ b/support/packaging/bintray.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# Usage: pushToBintray.sh RPM
+# The following environment variables must be set:
+#   BINTRAY_CREDS (In the form <username>:<api-key>)
+#   MESOS_TAG (1.4.0-rc1, 1.4.0, etc.)
+
+# The following default to "mesos" if not specified.
+#   BINTRAY_ORG
+#   BINTRAY_PKG
+
+
+# Sample yum repo file:
+# #bintray-mesos-el - packages by mesos from Bintray
+# [bintray-mesos-el]
+# name=bintray-mesos-el
+# baseurl=https://dl.bintray.com/mesos/el/7/x86_64
+# gpgcheck=0
+# repo_gpgcheck=0
+# enabled=1
+#
+# #bintray-mesos-el-srpm - source rpm packages by mesos from Bintray
+# [bintray-mesos-el-srpm]
+# name=bintray-mesos-el-srpm
+# baseurl=https://dl.bintray.com/mesos/el/7/SRPMS
+# gpgcheck=0
+# repo_gpgcheck=0
+# enabled=1
+
+set -o errexit -o nounset
+
+API=https://api.bintray.com
+
+BINTRAY_ORG=${BINTRAY_ORG:-mesos}
+BINTRAY_PKG=${BINTRAY_PKG:-mesos}
+
+PKG_PATH=$1
+PKG_FILENAME=$(basename $PKG_PATH)
+
+REPO_SUFFIX=""
+MESOS_VERSION=${MESOS_TAG%[-]*}
+case "$PKG_FILENAME" in
+  *.pre.*git*) REPO_SUFFIX="-unstable" ;;
+  *-rc*)       REPO_SUFFIX="-testing" ;;
+esac
+
+REPO_BASE=""
+if [ "${PKG_PATH##*.}" = "rpm" ]; then
+  REPO="el${REPO_SUFFIX}"
+fi
+
+REPO_PATH=""
+case "$PKG_PATH" in
+  *.el7.src.rpm)    REPO_PATH=7/SRPMS ;;
+  *.el6.src.rpm)    REPO_PATH=6/SRPMS ;;
+
+  *.el7.x86_64.rpm) REPO_PATH=7/x86_64 ;;
+  *.el6.x86_64.rpm) REPO_PATH=6/x86_64 ;;
+esac
+
+
+# Refer to https://bintray.com/docs/api/#_upload_content for Bintray upload API.
+# The following command is inspired from an example script provided by bintray:
+#  https://github.com/bintray/bintray-examples/blob/master/bash-example/pushToBintray.sh
+
+echo "Uploading ${PKG_FILENAME} to ${API}/content/${BINTRAY_ORG}/${REPO}/${REPO_PATH}/${PKG_FILENAME}..."
+
+result=$(curl                           \
+  -u${BINTRAY_CREDS}                    \
+  -H Content-Type:application/json      \
+  -H Accept:application/json            \
+  --write-out %{http_code}              \
+  --silent --output /dev/null           \
+  -T ${PKG_PATH}                        \
+  -H X-Bintray-Package:${BINTRAY_PKG}   \
+  -H X-Bintray-Version:${MESOS_VERSION} \
+  -H X-Bintray-Publish:1                \
+  ${API}/content/${BINTRAY_ORG}/${REPO}/${REPO_PATH}/${PKG_FILENAME})
+
+if [ $result -ne 201 ]; then
+  echo "Package ${PKG_FILENAME} upload to ${API}/content/${BINTRAY_ORG}/${REPO}/${REPO_PATH}/${PKG_FILENAME} failed with status ${result}"
+  exit 1
+fi

http://git-wip-us.apache.org/repos/asf/mesos/blob/1132e1dd/support/packaging/centos/build_rpm.sh
----------------------------------------------------------------------
diff --git a/support/packaging/centos/build_rpm.sh b/support/packaging/centos/build_rpm.sh
index 3a7a347..abb6d4d 100755
--- a/support/packaging/centos/build_rpm.sh
+++ b/support/packaging/centos/build_rpm.sh
@@ -4,11 +4,14 @@ CENTOS_VERSION=$(rpm --eval '%{centos_ver}')
 MESOS_VERSION=${MESOS_TAG%[-]*}
 MESOS_RELEASE=${MESOS_RELEASE:-1}
 
+PACKAGING_DIR=$(readlink -e "$(dirname "$(dirname "$0")")")
+MESOS_DIR=$(readlink -e $PACKAGING_DIR/../../)
+
+pushd "${MESOS_DIR}"
+
 export HOME="${PWD}/centos${CENTOS_VERSION}"
 mkdir -p $HOME/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
 
-PACKAGING_DIR=$(readlink -e "$(dirname "$(dirname "$0")")")
-MESOS_DIR=$(readlink -e $PACKAGING_DIR/../../)
 cp ${PACKAGING_DIR}/common/* $HOME/rpmbuild/SOURCES
 cp ${PACKAGING_DIR}/centos/mesos.spec $HOME/rpmbuild/SPECS