Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
pipeline {

agent {
docker {
label 'memphis-jenkins-big-fleet,'
image 'maven:3.8.4-openjdk-17'
args '-u root'
}
}

environment {
HOME = '/tmp'
GPG_PASSPHRASE = credentials('gpg-key-passphrase')
}

stages {
stage('Read Version from pom.xml') {
steps {
dir('superstream-clients'){
script {
// Read the version from pom.xml
def pomVersion = sh(
script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout",
returnStdout: true
).trim()

echo "Original version from pom.xml: ${pomVersion}"
env.BASE_VERSION = pomVersion
}
}

}
}

stage('Build and Deploy') {
steps {
script {
def branchName = env.BRANCH_NAME ?: ''
dir('superstream-clients'){
withCredentials([file(credentialsId: 'gpg-key', variable: 'GPG_KEY')]) {
// gpg --batch --import $GPG_KEY
sh '''
echo '${env.GPG_PASSPHRASE}' | gpg --batch --yes --passphrase-fd 0 --import $GPG_KEY
echo "allow-loopback-pinentry" > /tmp/.gnupg/gpg-agent.conf
echo "D64C041FB68170463BE78AD7C4E3F1A8A5F0A659:6:" | gpg --import-ownertrust
'''
}
withCredentials([file(credentialsId: 'settings-xml-superstream', variable: 'MAVEN_SETTINGS')]) {
sh "mvn -B package --file pom.xml"
if (branchName == 'master') {
def betaVersion = "${env.BASE_VERSION}-beta"
echo "Setting beta version: ${betaVersion}"
sh "mvn versions:set -DnewVersion=${betaVersion}"
}
sh "mvn -s $MAVEN_SETTINGS deploy -DautoPublish=true"
}
}
}
}
}

stage('Checkout to version branch'){
when {
expression { env.BRANCH_NAME == 'latest' }
}
steps {
sh """
curl -L https://github.com/cli/cli/releases/download/v2.40.0/gh_2.40.0_linux_amd64.tar.gz -o gh.tar.gz
tar -xvf gh.tar.gz
mv gh_2.40.0_linux_amd64/bin/gh /usr/local/bin
rm -rf gh_2.40.0_linux_amd64 gh.tar.gz
"""
withCredentials([sshUserPrivateKey(keyFileVariable:'check',credentialsId: 'main-github')]) {
sh """
GIT_SSH_COMMAND='ssh -i $check -o StrictHostKeyChecking=no' git checkout -b ${env.BASE_VERSION}
GIT_SSH_COMMAND='ssh -i $check -o StrictHostKeyChecking=no' git push --set-upstream origin ${env.BASE_VERSION}
"""
}
withCredentials([string(credentialsId: 'gh_token', variable: 'GH_TOKEN')]) {
sh """
gh release create ${env.BASE_VERSION} --generate-notes
"""
}
}
}
}
post {
always {
cleanWs()
}
}
}

108 changes: 81 additions & 27 deletions superstream-clients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>ai.superstream</groupId>
<artifactId>superstream-clients-java</artifactId>
<version>1.0.0</version>
</parent>

<groupId>ai.superstream</groupId>
<artifactId>superstream-clients</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Superstream Kafka Client Optimizer</name>
Expand All @@ -25,6 +21,14 @@
</license>
</licenses>

<developers>
<developer>
<id>superstreamlabs</id>
<name>Superstream Labs</name>
<email>support@superstream.ai</email>
</developer>
</developers>

<!-- SCM information -->
<scm>
<connection>scm:git:git://github.com/superstreamlabs/superstream-clients-java.git</connection>
Expand All @@ -34,15 +38,12 @@

<!-- Distribution management -->
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<repository>
<id>ai.superstream</id>
<name>superstream</name>
<url>https://central.sonatype.com</url>
</repository>
</distributionManagement>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down Expand Up @@ -204,24 +205,77 @@
</execution>
</executions>
</plugin>
<!-- Nexus Staging -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

<!-- maven-install-plugin -->
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<!-- central-publishing-maven-plugin -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<publishingServerId>central</publishingServerId>
<tokenAuth>true</tokenAuth>
<deploymentName>${project.artifactId}-${project.version}</deploymentName>
</configuration>
</execution>
</executions>
</plugin>
<!-- Disabling the default maven-deploy-plugin -->
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>A5F0A659</keyname> <!-- Your GPG key ID -->
<gpgArguments>
<arg>--batch</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>../</directory>
<includes>
<include>README.md</include>
</includes>
<targetPath>.</targetPath> <!-- place it in root of jar -->
</resource>
</resources>
</build>

Expand Down