mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
Merge branch 'master' of https://ecosystem.cloudogu.com/scm/git/qs-tag/spring-petclinic
This commit is contained in:
commit
d5d8a83ddc
6 changed files with 333 additions and 307 deletions
55
Jenkinsfile
vendored
55
Jenkinsfile
vendored
|
@ -1,9 +1,16 @@
|
|||
#!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()
|
||||
])
|
||||
|
||||
cesFqdn = findHostName()
|
||||
cesUrl = "https://${cesFqdn}"
|
||||
credentials = usernamePassword(credentialsId: 'scmCredentials', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')
|
||||
|
||||
catchError {
|
||||
|
||||
stage('Checkout') {
|
||||
checkout scm
|
||||
|
@ -16,13 +23,20 @@ node {
|
|||
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 verify ${jacoco}:report"
|
||||
|
||||
// Archive JUnit results, if any
|
||||
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'
|
||||
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]) {
|
||||
|
@ -37,15 +51,16 @@ node {
|
|||
String snapshotProp = "-DaltSnapshotDeploymentRepository=${cesFqdn}::default::${cesUrl}/nexus/content/repositories/snapshots/";
|
||||
mvn "-DskipTests deploy ${releaseProp} ${snapshotProp}"
|
||||
}
|
||||
|
||||
stage('Deploy Application') {
|
||||
sh "ansible-playbook playbook.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
String cesFqdn;
|
||||
String cesUrl;
|
||||
def credentials;
|
||||
// Archive Unit and integration test results, if any
|
||||
junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/TEST-*.xml,**/target/surefire-reports/TEST-*.xml'
|
||||
}
|
||||
|
||||
// Init global vars in order to avoid NPE
|
||||
String cesFqdn = ''
|
||||
String cesUrl = ''
|
||||
def credentials= {}
|
||||
|
||||
void mvn(String args) {
|
||||
writeSettingsXml()
|
||||
|
@ -53,6 +68,16 @@ void mvn(String 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: """
|
||||
|
|
7
docs/Home.md
Normal file
7
docs/Home.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Hello world!
|
||||
|
||||
Welcome to the Smeagol-Demo! Have some embedded PlantUML:
|
||||
|
||||
@startuml
|
||||
Bob -> Alice : hello
|
||||
@enduml
|
|
@ -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
|
||||
|
17
pom.xml
17
pom.xml
|
@ -142,6 +142,20 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
|
@ -194,7 +208,8 @@
|
|||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
||||
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
|
||||
</wroManagerFactory>
|
||||
<cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
|
||||
<wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
|
||||
<extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
[Unit]
|
||||
Description=spring-petclinic
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
User=deploy
|
||||
ExecStart=/opt/spring-petclinic.jar
|
||||
SuccessExitStatus=143
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,29 @@
|
|||
package org.springframework.samples.petclinic.owner;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class OwnerControllerITCase {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
/**
|
||||
* Note: This test exists only for the purpose of serving as an example! Please write tests more sensible
|
||||
* than this for your own applications.
|
||||
*/
|
||||
@Test
|
||||
public void assertsUser1IsGeorgeFranklin() {
|
||||
String body = this.restTemplate.getForObject("/owners/1", String.class);
|
||||
assertThat(body).contains("<td><b>George Franklin</b></td>");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue