Skip to content

Commit

Permalink
Support public release for plugin jar (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
firestarman authored Jun 18, 2020
1 parent 0813ee9 commit 4f92b9a
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 0 deletions.
1 change: 1 addition & 0 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<configuration>
<excludes>
<exclude>dependency-reduced-pom.xml</exclude>
<exclude>pom.xml.asc</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
103 changes: 103 additions & 0 deletions jenkins/Jenkinsfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/local/env groovy
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
*
* Licensed 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.
*/

/**
*
* Jenkinsfile for building and deploy rapids-plugin to public repo
*
*/

def SERVERS_MAP = [
Local: ' ',
Sonatype: 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
]

def SEC_IDS = [
Local: ['local-gpg-passphrase', 'local-gpg-private-key', 'local-username-password'],
Sonatype: ['rapids-gpg-passphrase', 'rapids-gpg-private-key', 'sonatype-username-password']
]

pipeline {
agent { label 'vanilla||docker-deploy||docker-gpu' }

options {
ansiColor('xterm')
timeout(time: 120, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '10'))
}

parameters {
choice(name: 'DEPLOY_TO', choices: ['Sonatype'],
description: 'Where to deploy artifacts to')
string(name: 'REF', defaultValue: 'branch-0.1', description: 'Commit to build')
}

environment {
JENKINS_ROOT='jenkins'
IMAGE_NAME="urm.nvidia.com/sw-spark-docker/plugin:dev-ubuntu16-cuda10.1"
LIBCUDF_KERNEL_CACHE_PATH='/tmp/.cudf'
MVN_MIRROR='-s jenkins/settings.xml -P mirror-apache-to-urm'
URM_CREDS = credentials("svcngcc_artifactory")
DIST_PL='dist'
SQL_PL='sql-plugin'
}

stages {
stage('Build') {
steps {
script {
def DOCKER_CMD="docker --config $WORKSPACE/.docker"
sh """
echo $URM_CREDS_PSW | $DOCKER_CMD login https://urm.nvidia.com -u $URM_CREDS_USR --password-stdin
$DOCKER_CMD pull $IMAGE_NAME
$DOCKER_CMD logout https://urm.nvidia.com
"""
docker.image("$IMAGE_NAME").inside("--runtime=nvidia -v ${HOME}/.m2:${HOME}/.m2:rw \
-v ${HOME}/.zinc:${HOME}/.zinc:rw \
-v /etc/passwd:/etc/passwd -v /etc/group:/etc/group") {
sh "mvn -U -B clean install $MVN_MIRROR -P source-javadoc"
}
}
}
}

stage("Deploy") {
environment {
SERVER_ID='ossrh'
SERVER_URL="${SERVERS_MAP["$DEPLOY_TO"]}"
GPG_PASSPHRASE=credentials("${SEC_IDS["$DEPLOY_TO"][0]}")
GPG_FILE=credentials("${SEC_IDS["$DEPLOY_TO"][1]}")
SONATYPE=credentials("${SEC_IDS["$DEPLOY_TO"][2]}")
GNUPGHOME="${WORKSPACE}/.gnupg"
}
steps {
script {
docker.image("$IMAGE_NAME").inside("-v ${HOME}/.m2:${HOME}/.m2:rw \
-v /etc/passwd:/etc/passwd -v /etc/group:/etc/group") {
sh 'rm -rf $GNUPGHOME'
sh 'gpg --import $GPG_FILE'
retry (3) {
sh "bash $JENKINS_ROOT/deploy.sh true"
}
}
}
}
}
} // End of stages

}

58 changes: 58 additions & 0 deletions jenkins/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
#
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Licensed 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.
#

set -e
SIGN_FILE=$1

###### Build the path of jar(s) to be deployed ######

cd $WORKSPACE
ART_ID=`mvn exec:exec -q -pl $DIST_PL -Dexec.executable=echo -Dexec.args='${project.artifactId}'`
ART_VER=`mvn exec:exec -q -pl $DIST_PL -Dexec.executable=echo -Dexec.args='${project.version}'`

FPATH="$DIST_PL/target/$ART_ID-$ART_VER"

echo "Plan to deploy ${FPATH}.jar to $SERVER_URL (ID:$SERVER_ID)"


###### Choose the deploy command ######

if [ "$SIGN_FILE" == true ]; then
# No javadoc and sources jar is generated for shade artifact only. Use 'sql-plugin' instead
SQL_ART_ID=`mvn exec:exec -q -pl $SQL_PL -Dexec.executable=echo -Dexec.args='${project.artifactId}'`
SQL_ART_VER=`mvn exec:exec -q -pl $SQL_PL -Dexec.executable=echo -Dexec.args='${project.version}'`
JS_FPATH="${SQL_PL}/target/${SQL_ART_ID}-${SQL_ART_VER}"
SRC_DOC_JARS="-Dsources=${JS_FPATH}-sources.jar -Djavadoc=${JS_FPATH}-javadoc.jar"
DEPLOY_CMD="mvn -B gpg:sign-and-deploy-file -s jenkins/settings.xml -Dgpg.passphrase=$GPG_PASSPHRASE"
else
DEPLOY_CMD="mvn -B deploy:deploy-file -s jenkins/settings.xml"
fi

echo "Deploy CMD: $DEPLOY_CMD"


###### Deploy the parent pom file ######

$DEPLOY_CMD -Durl=$SERVER_URL -DrepositoryId=$SERVER_ID \
-Dfile=./pom.xml -DpomFile=./pom.xml

###### Deploy the artifact jar(s) ######

$DEPLOY_CMD -Durl=$SERVER_URL -DrepositoryId=$SERVER_ID \
$SRC_DOC_JARS \
-Dfile=$FPATH.jar -DpomFile=${DIST_PL}/pom.xml

5 changes: 5 additions & 0 deletions jenkins/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<password>${env.URM_CREDS_PSW}</password>
<id>snapshots</id>
</server>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_USR}</username>
<password>${env.SONATYPE_PSW}</password>
</server>
</servers>
<profiles>
<profile>
Expand Down
65 changes: 65 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@
<version>0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<url>https://github.com/NVIDIA</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:https://github.com/NVIDIA/spark-rapids.git</connection>
<developerConnection>scm:git:[email protected]:NVIDIA/spark-rapids.git</developerConnection>
<tag>HEAD</tag>
<url>https://github.com/NVIDIA/spark-rapids</url>
</scm>
<developers>
<developer>
<id>revans2</id>
<name>Robert Evans</name>
<email>[email protected]</email>
<roles>
<role>Committer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>

<modules>
<module>dist</module>
<module>shuffle-plugin</module>
Expand All @@ -42,6 +68,42 @@
<rapids.shuffle.manager.override>true</rapids.shuffle.manager.override>
</properties>
</profile>
<profile>
<id>source-javadoc</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-source</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<properties>
Expand Down Expand Up @@ -381,6 +443,9 @@
<exclude>**/*.md</exclude>
<exclude>NOTICE-binary</exclude>
<exclude>docs/dev/idea-code-style-settings.xml</exclude>
<exclude>**/.m2/**</exclude>
<exclude>.gnupg/**</exclude>
<exclude>pom.xml.asc</exclude>
</excludes>
</configuration>
</plugin>
Expand Down

0 comments on commit 4f92b9a

Please sign in to comment.