Skip to content

Commit

Permalink
Build and publish to artifactory through Jenkins
Browse files Browse the repository at this point in the history
The commit includes changes to Build.xml to version the
jython-standalone jar file.The commit also includes
a Jenkinsfile which will be used to build the
project with ant and publish the artifacts to
artifactory.
  • Loading branch information
nisanth-datastax authored and venu-datastax committed Sep 4, 2024
1 parent 2821faa commit 8b54221
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 6 deletions.
73 changes: 73 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/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')]) {
withAnt(installation: 'ant-1.10.7') {
sh "ant installer"
sh "mkdir artifacts"
sh "cp dist/jython-standalone* artifacts/"
sh "cp dist/jython-installer* 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 {
script {
def directoryPath = 'artifacts'
def filenames = sh(script: "ls ${directoryPath}", returnStdout: true).trim().split('\n')

withCredentials([usernamePassword(credentialsId: 'dse-artifactory',
usernameVariable: 'ARTIFACTORY_USER',
passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
for (def filename in filenames) {
sh "echo $filename"
sh "curl -sSf -u '$ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD' -X PUT -T artifacts/$filename 'https://repo.aws.dsinternal.org/artifactory/datastax-public-releases-local/com/datastax/opscenter/jython-standalone/2.7.3a1/$filename'"
}
}
}
}
}
stage('wrapup') {
steps {
cleanWs notFailBuild: true
}
}
}
}
13 changes: 7 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ informix.jar = ../support/jdbc-4.10.12.jar
<property name="pubs.dir" value="${basedir}/publications" />
</target>

<target name="common-jars" depends="common-dirs">
<target name="common-jars" depends="common-dirs,common-version-strings">
<!-- Names of JARs we (may) produce according to target. -->

<!-- Target: jar. Just the Jython code: needs main.classpath to work. For dev & test. -->
Expand All @@ -195,9 +195,10 @@ informix.jar = ../support/jdbc-4.10.12.jar
<property name="jython.deploy.jar" value="jython.jar" />

<!-- Target: jar-standalone. jython.standalone.jar subsumes jython.deploy.jar, and
adds the Python library as a resource. A self-contained Python in a JAR. -->
<property name="jython.standalone.jar" value="jython-standalone.jar" />

adds the Python library as a resource. A self-contained Python in a JAR.
value="jython-standalone-${jython.release}${snapshot.name}.jar -->
<property name="jython.standalone.jar" value="jython-standalone-${jython.release}.jar" />
<property name="jython.installer.jar" value="jython-installer-${jython.release}.jar" />
<!-- Target: all-jars creates these and all the above JARs. -->
<property name="jython.javadoc.jar" value="javadoc.jar" />
<property name="jython.sources.jar" value="sources.jar" />
Expand Down Expand Up @@ -1195,9 +1196,9 @@ The text for an official release would continue like ...
</copy>

<echo>building installer .jar file</echo>
<jar destfile="${dist.dir}/jython-installer.jar" update="${jar.update}" roundup="false">
<jar destfile="${dist.dir}/${jython.installer.jar}" update="${jar.update}" roundup="false">
<fileset dir="${dist.dir}">
<exclude name="jython-installer.jar"/>
<exclude name="${jython.installer.jar}"/>
<exclude name="${jython.dev.jar}"/>
<exclude name="${jython.standalone.jar}"/>
<exclude name="${jython.javadoc.jar}"/>
Expand Down

0 comments on commit 8b54221

Please sign in to comment.