Commit 8a6f2a72 authored by Patrik Dufresne's avatar Patrik Dufresne

Fix gitlab CICD

parent d00d86bd
Pipeline #534 passed with stage
in 41 minutes and 28 seconds
image: maven:3-jdk-8
variables:
MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
-Dorg.slf4j.simpleLogger.showDateTime=true
-Djava.awt.headless=true
-Dmaven.repo.local=.m2/repository"
# Cache downloaded dependencies and plugins between builds.
cache:
paths:
- .m2/repository
stages:
- build
before_script:
- export REVISION="$(curl http://git.patrikdufresne.com/pdsl/maven-scm-version/raw/master/version.sh | bash -)"
- echo "REVISION=$REVISION"
test_deploy:
stage: build
script:
- apt-get update && apt-get install -y default-jdk swig build-essential gcc-mingw-w64 mingw-w64 g++-multilib
- mvn -B -s ./settings.xml -Drevision=${REVISION} clean install deploy
sonar:
stage: build
allow_failure: true
script:
- apt-get update && apt-get install -y default-jdk swig build-essential gcc-mingw-w64 mingw-w64 g++-multilib
- mvn -B -Drevision=${REVISION} -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN clean verify sonar:sonar
pipeline {
environment {
NEXUS = credentials("local-nexus")
GITLAB = credentials("gitlab-jenkins")
GITHUB = credentials("github")
}
parameters {
booleanParam(defaultValue: false, description: 'Generate a release build with a tagged version.', name: 'Release')
}
agent {
docker {
image 'jamesdbloom/docker-java7-maven'
args '-v $HOME/.m2:/root/.m2'
}
}
stages {
stage ('Setup') {
steps {
sh 'apt-get update && apt-get -qq install maven swig build-essential gcc-mingw-w64 mingw-w64 g++-multilib'
}
}
stage ('Build') {
steps {
writeFile file: "settings.xml", text: "<settings><servers><server><id>patrikdufresne</id><username>${NEXUS_USR}</username><password>${NEXUS_PSW}</password></server></servers></settings>"
sh 'mvn --settings settings.xml -U -Dmaven.test.failure.ignore=true clean deploy'
}
}
stage ('Release') {
when {
environment name: 'Release', value: 'true'
}
steps {
script {
// We want to pick up the version from the pom
pom = readMavenPom file: 'pom.xml'
version = pom.version.replace("-SNAPSHOT", "-${BUILD_NUMBER}")
}
sh 'git checkout .'
sh "mvn versions:set -DnewVersion=${version}"
sh "mvn --settings settings.xml -U -Dmaven.test.skip=true deploy"
sh """
git config --local user.email "jenkins@patrikdufresne.com"
git config --local user.name "Jenkins"
git tag 'v${version}'
export REPO=`git config remote.origin.url`
git push http://${GITLAB}@\044{REPO#*//} --tags
"""
addInfoBadge "v${version}"
}
}
stage('GitHubPush') {
steps {
sh "git push --force https://${GITHUB}@github.com/ikus060/cbc4j.git refs/remotes/origin/${BRANCH_NAME}:refs/heads/${BRANCH_NAME}"
sh "git push https://${GITHUB}@github.com/ikus060/cbc4j.git --tags"
}
}
}
}
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.patrikdufresne.cbc4j</groupId>
<artifactId>cbc4j-root</artifactId>
<version>1.2-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>cbc4j-linux-x86_64</artifactId>
<properties>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.patrikdufresne.cbc4j</groupId>
<artifactId>cbc4j-root</artifactId>
<version>1.2-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>cbc4j-win-i686</artifactId>
<properties>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.patrikdufresne.cbc4j</groupId>
<artifactId>cbc4j-root</artifactId>
<version>1.2-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>cbc4j-win-x86_64</artifactId>
<properties>
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.patrikdufresne.cbc4j</groupId>
<artifactId>cbc4j-root</artifactId>
<version>1.2-SNAPSHOT</version>
<version>${revision}</version>
<packaging>pom</packaging>
<name>cbc4j-root</name>
<!-- Define the SCM used for developpement. This information is used by
......@@ -48,8 +48,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- generate source package for all sub-project -->
......
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>patrikdufresne</id>
<username>${env.NEXUS_USR}</username>
<password>${env.NEXUS_PWD}</password>
</server>
</servers>
</settings>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment