mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 21:45:49 +00:00
Jenkins: Discover FQDN from env var instead of using hard-coded one.
Makes pipeline less dependent to environment.
This commit is contained in:
parent
ef3e3defd4
commit
b5b2dcf1c1
1 changed files with 12 additions and 2 deletions
14
Jenkinsfile
vendored
14
Jenkinsfile
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!groovy
|
#!groovy
|
||||||
node {
|
node {
|
||||||
|
|
||||||
cesFqdn = "ecosystem.cloudogu.net"
|
cesFqdn = findHostName()
|
||||||
cesUrl = "https://${cesFqdn}"
|
cesUrl = "https://${cesFqdn}"
|
||||||
credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')
|
credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ node {
|
||||||
parallel(
|
parallel(
|
||||||
test: {
|
test: {
|
||||||
stage('Test') {
|
stage('Test') {
|
||||||
String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606";
|
String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606"
|
||||||
mvn "${jacoco}:prepare-agent test ${jacoco}:report"
|
mvn "${jacoco}:prepare-agent test ${jacoco}:report"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -72,6 +72,16 @@ void mvn(String args) {
|
||||||
sh 'rm -f settings.xml'
|
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() {
|
void writeSettingsXml() {
|
||||||
withCredentials([credentials]) {
|
withCredentials([credentials]) {
|
||||||
writeFile file: "settings.xml", text: """
|
writeFile file: "settings.xml", text: """
|
||||||
|
|
Loading…
Reference in a new issue