mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 22:15:50 +00:00
Introduces ces-build-lib for maven and deployment to nexus
This commit is contained in:
parent
d5d8a83ddc
commit
d94ecfaa3f
1 changed files with 14 additions and 49 deletions
59
Jenkinsfile
vendored
59
Jenkinsfile
vendored
|
@ -1,14 +1,19 @@
|
||||||
#!groovy
|
#!groovy
|
||||||
node {
|
@Library('github.com/cloudogu/ces-build-lib@caa9632')
|
||||||
|
import com.cloudogu.ces.cesbuildlib.*
|
||||||
|
|
||||||
properties([
|
properties([
|
||||||
// Don't run concurrent builds, because the ITs use the same port causing random failures on concurrent builds.
|
// Don't run concurrent builds, because the ITs use the same port causing random failures on concurrent builds.
|
||||||
disableConcurrentBuilds()
|
disableConcurrentBuilds()
|
||||||
])
|
])
|
||||||
|
|
||||||
|
node {
|
||||||
|
|
||||||
cesFqdn = findHostName()
|
cesFqdn = findHostName()
|
||||||
cesUrl = "https://${cesFqdn}"
|
cesUrl = "https://${cesFqdn}"
|
||||||
credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')
|
String credentialsId = 'scmCredentials'
|
||||||
|
|
||||||
|
Maven mvn = new MavenWrapper(this)
|
||||||
|
|
||||||
catchError {
|
catchError {
|
||||||
|
|
||||||
|
@ -39,7 +44,8 @@ node {
|
||||||
)
|
)
|
||||||
|
|
||||||
stage('SonarQube Analysis') {
|
stage('SonarQube Analysis') {
|
||||||
withCredentials([credentials]) {
|
withCredentials([usernamePassword(credentialsId: credentialsId,
|
||||||
|
passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
|
||||||
//noinspection GroovyAssignabilityCheck
|
//noinspection GroovyAssignabilityCheck
|
||||||
mvn "org.codehaus.mojo:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=${cesUrl}/sonar " +
|
mvn "org.codehaus.mojo:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=${cesUrl}/sonar " +
|
||||||
"-Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD} -Dsonar.exclusions=target/**"
|
"-Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD} -Dsonar.exclusions=target/**"
|
||||||
|
@ -47,9 +53,9 @@ node {
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Deploy Artifacts') {
|
stage('Deploy Artifacts') {
|
||||||
String releaseProp = "-DaltReleaseDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/releases/";
|
mvn.setDeploymentRepository(cesFqdn, "${cesUrl}/nexus", credentialsId)
|
||||||
String snapshotProp = "-DaltSnapshotDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/snapshots/";
|
|
||||||
mvn "-DskipTests deploy ${releaseProp} ${snapshotProp}"
|
mvn.deployToNexusRepository('-Dmaven.javadoc.failOnError=false')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,44 +66,3 @@ node {
|
||||||
// Init global vars in order to avoid NPE
|
// Init global vars in order to avoid NPE
|
||||||
String cesFqdn = ''
|
String cesFqdn = ''
|
||||||
String cesUrl = ''
|
String cesUrl = ''
|
||||||
def credentials= {}
|
|
||||||
|
|
||||||
void mvn(String args) {
|
|
||||||
writeSettingsXml()
|
|
||||||
sh "./mvnw -s settings.xml --batch-mode -V -U -e -Dsurefire.useFile=false ${args}"
|
|
||||||
sh 'rm -f settings.xml'
|
|
||||||
}
|
|
||||||
|
|
||||||
String findHostName() {
|
|
||||||
String regexMatchesHostName = 'https?://([^:/]*)'
|
|
||||||
|
|
||||||
// Storing matcher in a variable might lead to java.io.NotSerializableException: java.util.regex.Matcher
|
|
||||||
if (!(env.JENKINS_URL =~ regexMatchesHostName)) {
|
|
||||||
script.error 'Unable to determine hostname from env.JENKINS_URL. Expecting http(s)://server:port/jenkins'
|
|
||||||
}
|
|
||||||
return (env.JENKINS_URL =~ regexMatchesHostName)[0][1]
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeSettingsXml() {
|
|
||||||
withCredentials([credentials]) {
|
|
||||||
writeFile file: "settings.xml", text: """
|
|
||||||
<settings>
|
|
||||||
<localRepository>${env.HOME}/.m2/repository</localRepository>
|
|
||||||
<servers>
|
|
||||||
<server>
|
|
||||||
<id>${cesFqdn}</id>
|
|
||||||
<username>${USERNAME}</username>
|
|
||||||
<password>${PASSWORD}</password>
|
|
||||||
</server>
|
|
||||||
</servers>
|
|
||||||
<mirrors>
|
|
||||||
<mirror>
|
|
||||||
<id>${cesFqdn}</id>
|
|
||||||
<name>${cesFqdn} Central Mirror</name>
|
|
||||||
<url>${cesUrl}/nexus/content/groups/public</url>
|
|
||||||
<mirrorOf>central</mirrorOf>
|
|
||||||
</mirror>
|
|
||||||
</mirrors>
|
|
||||||
</settings>"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue