From d2f4171bb0ed33c61a7234614be9595d28d9d9f9 Mon Sep 17 00:00:00 2001 From: nisanth-datastax Date: Fri, 5 Jul 2024 14:32:20 +0530 Subject: [PATCH] Build and publish to artifactory through Jenkins The commit includes changes to Build.xml to use ivy to publish the artifacts to artifactory. ivy uses ivy.xml and ivysettings.xml to publish the artifacts. The commit also includes Jenkinsfile which will build the project with ant and publish the artifacts to artifactory. --- Jenkinsfile | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ build.xml | 16 ++++++--- ivy.xml | 9 +++++ ivysettings.xml | 35 ++++++++++++++++++ 4 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 Jenkinsfile create mode 100644 ivy.xml create mode 100644 ivysettings.xml diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..72c556383 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,94 @@ +#!/usr/bin/env groovy + +@Library('ds-pipeline-lib') + +import java.security.MessageDigest +def id = MessageDigest.getInstance("MD5").digest(System.currentTimeMillis().toString().bytes).encodeHex().toString().substring(0,8) + +// Build Jython forked repository and push artifacts to artifactory + +pipeline { + agent { + node { + label 'default-runner' + customWorkspace "workspace/${BUILD_NUMBER}-package-build-${id}" + } + } + + tools { + jdk('jdk-8') + } + + parameters { + string(name: 'buildbranch', defaultValue: 'OPSC-16690', description: 'The branch to build. Only valid for the branch build job.') + } + + options { + disableConcurrentBuilds() + buildDiscarder(logRotator(numToKeepStr: '30')) + timeout(time: 120, unit: 'MINUTES') + timestamps() + } + + stages { + stage('Build') { + steps { + configFileProvider([configFile(fileId: 'gradle.properties', + replaceTokens: true, + targetLocation: 'gradle.properties')]) { + withCredentials([usernamePassword(credentialsId: 'dse-artifactory', + usernameVariable: 'ARTIFACTORY_USER', + passwordVariable: 'ARTIFACTORY_PASSWORD')]) { + withAnt(installation: 'ant-1.10.7') { + sh "curl -O https://repo1.maven.org/maven2/org/apache/ivy/ivy/2.5.2/ivy-2.5.2.jar" + script { + if (!fileExists('/home/ubuntu/.ant/')) { + sh "mkdir /home/ubuntu/.ant/" + } + if (!fileExists('/home/ubuntu/.ant/lib')) { + sh "mkdir /home/ubuntu/.ant/lib" + } + } + sh "cp ivy-2.5.2.jar /home/ubuntu/.ant/lib/" + sh "export ARTIFACTORY_USER=$ARTIFACTORY_USER" + sh "export ARTIFACTORY_PASSWORD=$ARTIFACTORY_PASSWORD" + sh "ant publish" + // sh "ant installer" + sh "mkdir artifacts" + sh "cp dist/jython-standalone* artifacts/" + } + } + } + archiveArtifacts artifacts: 'dist/jython-standalone-*.jar', onlyIfSuccessful: true, defaultExcludes: false, caseSensitive: false + archiveArtifacts artifacts: 'dist/jython-installer.jar', onlyIfSuccessful: true, defaultExcludes: false, caseSensitive: false + } + } + stage ('Upload to artifactory') { + steps { + sh "ls artifacts/ > commandResult" + + script { + env.jarfilename = readFile('commandResult').trim() + } + sh "echo $jarfilename" + + withCredentials([usernamePassword(credentialsId: 'dse-artifactory', + usernameVariable: 'ARTIFACTORY_USER', + passwordVariable: 'ARTIFACTORY_PASSWORD')]) { + // sh "curl -sSf -u '$ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD' -X PUT -T artifacts/$jarfilename 'https://repo.aws.dsinternal.org/ui/native/dse/com/datastax/opscenter/jython-standalone/2.7.3a1/$jarfilename'" + sh "curl -v --user $ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD --data-binary artifacts/$jarfilename -X PUT 'https://repo.aws.dsinternal.org/ui/native/dse/com/datastax/opscenter/jython-standalone/2.7.3a1/$jarfilename'" + // sh "curl -v --user $ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD --data-binary artifacts/$jarfilename -d 99999999 -X PUT 'https://repo.aws.dsinternal.org/artifactory/datastax-releases-local/com/datastax/opscenter/jython-standalone/2.7.3a1/$jarfilename'" + // maven(installation: 'maven_3_3_3') { + // sh "maven-publish --help" + // } + } + cleanWs notFailBuild: true + } + } + stage('wrapup') { + steps { + cleanWs notFailBuild: true + } + } + } +} diff --git a/build.xml b/build.xml index 43ad42838..354f1091a 100644 --- a/build.xml +++ b/build.xml @@ -3,7 +3,7 @@ Further development (c)2019 Jython Developers Licensed to the PSF under a Contributor Agreement. --> - + @@ -82,6 +82,13 @@ informix.jar = ../support/jdbc-4.10.12.jar depends="installer-preinit, jar-installer" description="build a snapshot installer from the current state" /> + + + + + + + @@ -184,7 +191,7 @@ informix.jar = ../support/jdbc-4.10.12.jar - + @@ -195,8 +202,9 @@ informix.jar = ../support/jdbc-4.10.12.jar - + adds the Python library as a resource. A self-contained Python in a JAR. + value="jython-standalone-${jython.release}${snapshot.name}.jar --> + diff --git a/ivy.xml b/ivy.xml new file mode 100644 index 000000000..7f75067fc --- /dev/null +++ b/ivy.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ivysettings.xml b/ivysettings.xml new file mode 100644 index 000000000..2d2c5b18d --- /dev/null +++ b/ivysettings.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file