diff --git a/Jenkinsfile b/Jenkinsfile
index 24038cb06..f102d0f1f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,56 +1,81 @@
#!groovy
node {
- cesFqdn = "ecosystem.cloudogu.net";
- cesUrl = "https://${cesFqdn}";
- credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME');
+ properties([
+ // Don't run concurrent builds, because the ITs use the same port causing random failures on concurrent builds.
+ disableConcurrentBuilds()
+ ])
- stage('Checkout') {
- checkout scm
- }
+ cesFqdn = findHostName()
+ cesUrl = "https://${cesFqdn}"
+ credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')
- stage('Build') {
- mvn "-DskipTests clean package"
+ catchError {
- // archive artifact
- archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
- }
+ stage('Checkout') {
+ checkout scm
+ }
- stage('Test') {
- String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606";
- mvn "${jacoco}:prepare-agent verify ${jacoco}:report"
+ stage('Build') {
+ mvn "-DskipTests clean package"
- // Archive JUnit results, if any
- junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'
- }
-
- stage('SonarQube Analysis') {
- withCredentials([credentials]) {
- //noinspection GroovyAssignabilityCheck
- mvn "org.codehaus.mojo:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=${cesUrl}/sonar " +
- "-Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD} -Dsonar.exclusions=target/**"
+ // archive artifact
+ archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
+ }
+
+ parallel(
+ test: {
+ stage('Test') {
+ String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606"
+ mvn "${jacoco}:prepare-agent test ${jacoco}:report"
+ }
+ },
+ integrationTest: {
+ stage('Integration Test') {
+ String jacoco = "org.jacoco:jacoco-maven-plugin:0.7.7.201606060606";
+ mvn "${jacoco}:prepare-agent-integration failsafe:integration-test ${jacoco}:report-integration"
+ }
+ }
+ )
+
+ stage('SonarQube Analysis') {
+ withCredentials([credentials]) {
+ //noinspection GroovyAssignabilityCheck
+ mvn "org.codehaus.mojo:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=${cesUrl}/sonar " +
+ "-Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD} -Dsonar.exclusions=target/**"
+ }
+ }
+
+ stage('Deploy Artifacts') {
+ String releaseProp = "-DaltReleaseDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/releases/";
+ String snapshotProp = "-DaltSnapshotDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/snapshots/";
+ mvn "-DskipTests deploy ${releaseProp} ${snapshotProp}"
}
}
- stage('Deploy Artifacts') {
- String releaseProp = "-DaltReleaseDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/releases/";
- String snapshotProp = "-DaltSnapshotDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/snapshots/";
- mvn "-DskipTests deploy ${releaseProp} ${snapshotProp}"
- }
-
- stage('Deploy Application') {
- sh "ansible-playbook playbook.yaml"
- }
+ // Archive Unit and integration test results, if any
+ junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/TEST-*.xml,**/target/surefire-reports/TEST-*.xml'
}
-String cesFqdn;
-String cesUrl;
-def credentials;
+// Init global vars in order to avoid NPE
+String cesFqdn = ''
+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'
+ 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() {
diff --git a/docs/Home.md b/docs/Home.md
new file mode 100644
index 000000000..26e6186e9
--- /dev/null
+++ b/docs/Home.md
@@ -0,0 +1,7 @@
+# Hello world!
+
+Welcome to the Smeagol-Demo! Have some embedded PlantUML:
+
+@startuml
+Bob -> Alice : hello
+@enduml
diff --git a/playbook.yaml b/playbook.yaml
deleted file mode 100644
index ba33b91d8..000000000
--- a/playbook.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
----
-
-- hosts: all
- become: yes
- gather_facts: yes
-
- tasks:
- - name: Copy systemd descriptor
- copy:
- src: src/main/systemd/spring-petclinic.service
- dest: /etc/systemd/system/spring-petclinic.service
- notify:
- - reload systemd
-
- - name: Copy spring-petclinic
- copy:
- src: target/spring-petclinic.jar
- dest: /opt/spring-petclinic.jar
- owner: deploy
- mode: u+rwx
- notify:
- - restart service
-
- - name: Enable service
- service:
- name: spring-petclinic
- enabled: yes
-
- handlers:
- - name: reload systemd
- systemd:
- name: spring-petclinic
- daemon_reload: yes
-
- - name: restart service
- service:
- name: spring-petclinic
- state: restarted
-
diff --git a/pom.xml b/pom.xml
index a8a1eec00..776cd1a43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,230 +1,245 @@