Skip to content

Instantly share code, notes, and snippets.

@cyrille-leclerc
Created January 24, 2016 23:48
Show Gist options
  • Save cyrille-leclerc/552e3103139557e0196a to your computer and use it in GitHub Desktop.
Save cyrille-leclerc/552e3103139557e0196a to your computer and use it in GitHub Desktop.
Jenkins Pipeline Script for maven-release-plugin
#!groovy
docker.image('cloudbees/java-build-tools:0.0.6').inside {
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
extensions: [
/* [$class: 'UserIdentity', email: '[email protected]', name: 'Jenkins as a Service'], */
[$class: 'WipeWorkspace'],
[$class: 'LocalBranch', localBranch: 'master']],
userRemoteConfigs: [[credentialsId: 'github-credentials', url: 'https://github.com/cyrille-leclerc/my-spring-boot-app.git']]])
stage 'Release'
def mavenSettingsFile = "${pwd()}/.m2/settings.xml"
wrap([$class: 'ConfigFileBuildWrapper',
managedFiles: [
[fileId: 'maven-settings-for-my-spring-boot-app', targetLocation: "${mavenSettingsFile}"]]]) {
sh """
git config --global user.email [email protected]
git config --global user.name JenkinsAsaService
"""
sh "mvn -s ${mavenSettingsFile} --batch-mode release:clean release:prepare release:perform"
step([$class: 'ArtifactArchiver', artifacts: 'target/checkout/target/*.jar'])
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>
<groupId>com.example</groupId>
<artifactId>my-spring-boot-app</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>jar</packaging>
<name>my-spring-boot-app</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath />
</parent>
<scm>
<connection>scm:git:https://github.com/cyrille-leclerc/my-spring-boot-app.git</connection>
<url>https://github.com/cyrille-leclerc/my-spring-boot-app</url>
<tag>HEAD</tag>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<project.scm.id>github</project.scm.id>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>nexus.beesshop.org</id>
<url>http://nexus.beesshop.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>nexus.beesshop.org</id>
<url>http://nexus.beesshop.org/content/repositories/releases</url>
</repository>
</distributionManagement>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment