Commit bf444bbf authored by Jan Belle's avatar Jan Belle
Browse files

Implement Jenkins pipeline

parent 2a869e81
Pipeline #2305 passed with stage
in 0 seconds
// See https://wiki.eclipse.org/Jenkins for information about the Eclipse Jenkins continuous integration server
pipeline {
agent {
kubernetes {
label 'migration'
}
}
tools {
maven 'apache-maven-latest'
jdk 'adoptopenjdk-hotspot-jdk11-latest'
}
options {
timeout(time: 60, unit: 'MINUTES')
}
// We change the Gradle home directory because we don't have access rights to the default location ${USER_HOME}/.gradle.
// Usually this is possible by setting the GRADLE_USER_HOME environment variable. However, this doesn't work here for some reason.
// environment {
// GRADLE_USER_HOME = './gradle_home'
// }
stages {
stage('Build') {
steps {
sh 'chmod +x gradlew'
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
sh './gradlew clean build -Pmaven -Psign -Dgradle.user.home=./gradle_home'
}
}
}
stage('Deploy') {
when {
branch 'master'
}
steps {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh './gradlew promote publishEtricePublicationToEclipseRepository -Dgradle.user.home=./gradle_home -PadditionalPropertiesFile=${env.USER_HOME}/.gradle/gradle.properties'
}
}
}
}
post {
always {
archiveArtifacts '*/*/build/**'
junit 'tests/*/target/surefire-reports/**/*.xml, tests/*/build/log/**/*.xml'
}
// send a mail on unsuccessful and fixed builds
unsuccessful { // means unstable || failure || aborted
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()]
}
fixed { // back to normal
emailext subject: 'Build $BUILD_STATUS $PROJECT_NAME #$BUILD_NUMBER!',
body: '''Check console output at $BUILD_URL to view the results.''',
recipientProviders: [culprits(), requestor()]
}
}
}
\ No newline at end of file
......@@ -9,62 +9,60 @@ configurations {
// The maven tycho build is disabled unless the 'maven' property is defined because
// maven might not be installed and we have to update the version strings in many files.
if(project.hasProperty('maven')) {
// Update version strings in manifest, feature and pom files for tycho.
task updateVersionStrings {
onlyIf { tycho.enabled }
doLast {
def manifestVersion = "${scmVersion.undecoratedVersion}.qualifier"
// Replace plugin versions
ant.replaceregexp(
match: "Bundle-Version:\\s*[\\w.-]*",
replace: "Bundle-Version: $manifestVersion") {
fileset(dir: rootDir, includes: '**/MANIFEST.MF')
}
// Replace feature versions
ant.replaceregexp(
match: "(?s)<feature(.*?)version\\s*=\\s*\"[\\w.-]*\"(.*)>",
replace: "<feature\\1version=\"$manifestVersion\"\\2>") {
fileset(dir: rootDir, includes: '**/feature.xml')
}
// Replace first occurence of version tag in poms
ant.replaceregexp(
match: "(?s)(.*?)<version>[\\w.-]*</version>(.*)",
replace: "\\1<version>$version</version>\\2") {
fileset(dir: rootDir, includes: '**/pom.xml')
}
}
}
def tychoEnabled = project.hasProperty('maven')
// The 'maven' property optionally provides the path to the maven installation.
// The 'sign' property enables artifact signing.
task tycho(type: MavenExec, dependsOn: updateVersionStrings) {
def mavenPath = project.property('maven')
if(!mavenPath.empty) {
mavenDir = rootProject.file(mavenPath)
// Update version strings in manifest, feature and pom files for tycho.
task updateVersionStrings {
enabled = tychoEnabled
doLast {
def manifestVersion = "${scmVersion.undecoratedVersion}.qualifier"
// Replace plugin versions
ant.replaceregexp(
match: "Bundle-Version:\\s*[\\w.-]*",
replace: "Bundle-Version: $manifestVersion") {
fileset(dir: rootDir, includes: '**/MANIFEST.MF')
}
// Replace feature versions
ant.replaceregexp(
match: "(?s)<feature(.*?)version\\s*=\\s*\"[\\w.-]*\"(.*)>",
replace: "<feature\\1version=\"$manifestVersion\"\\2>") {
fileset(dir: rootDir, includes: '**/feature.xml')
}
workingDir rootDir
goals 'clean', 'verify'
options {
define = ['build.type' : version.endsWith('SNAPSHOT') ? 'N' : 'R']
if(project.hasProperty('sign')) {
activateProfiles = ['sign']
}
// Replace first occurence of version tag in poms
ant.replaceregexp(
match: "(?s)(.*?)<version>[\\w.-]*</version>(.*)",
replace: "\\1<version>$version</version>\\2") {
fileset(dir: rootDir, includes: '**/pom.xml')
}
}
}
task zipSite(type: Zip, dependsOn: tycho) {
archiveBaseName = project.name
archiveVersion = project.version
destinationDirectory = layout.buildDirectory
from layout.projectDirectory.dir('target/repository')
// The 'maven' property optionally provides the path to the maven installation.
// The 'sign' property enables artifact signing.
task tycho(type: MavenExec, dependsOn: updateVersionStrings) {
enabled = tychoEnabled
workingDir rootDir
goals 'clean', 'verify'
options {
define = ['build.type' : version.endsWith('SNAPSHOT') ? 'N' : 'R']
if(project.hasProperty('sign')) {
activateProfiles = ['sign']
}
}
assemble.dependsOn zipSite
}
artifacts {
archive zipSite
update(layout.projectDirectory.dir('target/repository')) {
builtBy tycho
}
task zipSite(type: Zip, dependsOn: tycho) {
enabled = tychoEnabled
archiveBaseName = project.name
archiveVersion = project.version
destinationDirectory = layout.buildDirectory
from layout.projectDirectory.dir('target/repository')
}
assemble.dependsOn zipSite
artifacts {
archive zipSite
update(layout.projectDirectory.dir('target/repository')) {
builtBy tycho
}
}
\ 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