Merge branch 'develop'
* develop: jenkins: buid with java 9 first for test, then install with 8 jenkins: don't run builds in parallel jenkins: only enter some stages when suitable files exist jenkins: report environment, no snapshots in PRs to master and only deploy from https repos jenkins: Remove redundant Prepare stage lombok.config: added to prevent generated annotation jenkins: build and deploy using Java 9 jenkins: update to latest template Update set-version to better detect current version version set to 5.2.0-SNAPSHOT
This commit is contained in:
commit
48e6588b25
5 changed files with 83 additions and 31 deletions
28
Jenkinsfile
vendored
28
Jenkinsfile
vendored
|
@ -1,28 +0,0 @@
|
|||
final String gitRepoUrl = 'git@github.com:kemitix/kemitix-parent.git'
|
||||
final String mvn = "mvn --batch-mode --update-snapshots"
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Prepare') {
|
||||
steps {
|
||||
git url: gitRepoUrl, branch: '**', credentialsId: 'github-kemitix'
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||
sh "${mvn} clean install"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
when { expression { (env.GIT_BRANCH == 'master') } }
|
||||
steps {
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||
sh "${mvn} deploy --activate-profiles release"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
Jenkinsfile.groovy
Normal file
75
Jenkinsfile.groovy
Normal file
|
@ -0,0 +1,75 @@
|
|||
final String mvn = "mvn --batch-mode --update-snapshots"
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Environment') {
|
||||
steps {
|
||||
sh 'set'
|
||||
}
|
||||
}
|
||||
stage('no SNAPSHOT in master') {
|
||||
// checks that the pom version is not a snapshot when the current or target branch is master
|
||||
when {
|
||||
expression {
|
||||
(env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') &&
|
||||
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
||||
}
|
||||
}
|
||||
steps {
|
||||
error("Build failed because SNAPSHOT version")
|
||||
}
|
||||
}
|
||||
stage('Static Code Analysis') {
|
||||
when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } }
|
||||
steps {
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||
sh "${mvn} compile checkstyle:checkstyle pmd:pmd"
|
||||
}
|
||||
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
|
||||
}
|
||||
}
|
||||
stage('Build Java 9') {
|
||||
steps {
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
||||
sh "${mvn} clean install"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Java 8') {
|
||||
steps {
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||
sh "${mvn} clean install"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test Results') {
|
||||
when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } }
|
||||
steps {
|
||||
junit '**/target/surefire-reports/*.xml'
|
||||
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||
sh "${mvn} com.gavinmogan:codacy-maven-plugin:coverage " +
|
||||
"-DcoverageReportFile=target/site/jacoco/jacoco.xml " +
|
||||
"-DprojectToken=`$JENKINS_HOME/codacy/token` " +
|
||||
"-DapiToken=`$JENKINS_HOME/codacy/apitoken` " +
|
||||
"-Dcommit=`git rev-parse HEAD`"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving') {
|
||||
when { expression { findFiles(glob: '**/target/*.jar').length > 0 } }
|
||||
steps {
|
||||
archiveArtifacts '**/target/*.jar'
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } }
|
||||
steps {
|
||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||
sh "${mvn} deploy --activate-profiles release -DskipTests=true"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
lombok.config
Normal file
1
lombok.config
Normal file
|
@ -0,0 +1 @@
|
|||
lombok.addGeneratedAnnotation=false
|
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
|||
|
||||
<groupId>net.kemitix</groupId>
|
||||
<artifactId>kemitix-parent</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Kemitix Parent</name>
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd `dirname $0`
|
||||
PROJECT=`basename $PWD`
|
||||
|
||||
if test $# != 1
|
||||
then
|
||||
echo "next version missing"
|
||||
exit
|
||||
fi
|
||||
|
||||
CURRENT=`grep '<version>' pom.xml |head -n 1| sed 's/.*>\(.*\)<.*/\1/'`
|
||||
CURRENT=`grep -C 2 "<artifactId>${PROJECT}</artifactId>" pom.xml | grep '<version>' | sed 's/.*>\(.*\)<.*/\1/'`
|
||||
NEXT=$1
|
||||
|
||||
echo Updating version from $CURRENT to $NEXT
|
||||
|
||||
./mvnw versions:set -DnewVersion=$NEXT
|
||||
perl -p -i -e "s,$CURRENT</,$NEXT</," README.md
|
||||
./mvnw -pl parent versions:set -DnewVersion=$NEXT
|
||||
perl -p -i -e "s,$CURRENT</,$NEXT</," all/tile.xml README.md
|
||||
|
|
Loading…
Reference in a new issue