Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
159 lines (148 sloc) 4.37 KB
//Update kubernetes-plugin to 1.7
pipeline {
agent none //Using different agent for each stage
stages {
/********
* Build the jar and the docker image using the default 'maven' node
********/
stage('Build App and Image') {
agent{ label 'maven' }
steps {
dir ("app-users") {
sh "mvn -B -s ../configuration/settings.xml -DskipTests package"
// Requires: minishift config set insecure-registry 172.30.0.0/16
sh "oc new-build --name=app-users --docker-image=registry.access.redhat.com/fuse7/fuse-java-openshift:latest --binary=true --labels=app=app-users || true"
sh 'rm -rf oc-build && mkdir -p oc-build/deployments'
sh 'cp target/*.jar oc-build/deployments'
script {
openshift.withCluster() {
openshift.withProject('myproject') {
openshift.selector('bc', 'app-users').startBuild('--from-dir=oc-build', '--wait=true').logs('-f')
}
}
}
}
}
}
/********
* Run the integration test with the custom pod defined with a yaml
********/
stage('Run integration test') {
agent{
kubernetes {
label 'app-users-it'
cloud 'openshift'
defaultContainer 'jnlp'
yaml '''
apiVersion: v1
kind: Pod
metadata:
labels:
app: app-users
spec:
containers:
#Java agent, test executor
- name: jnlp
image: registry.access.redhat.com/openshift3/jenkins-slave-maven-rhel7:v3.9
command:
- /bin/sh
args:
- -c
- umask 0000; /usr/local/bin/run-jnlp-client $(JENKINS_SECRET) $(JENKINS_NAME)
resources:
limits:
memory: 512Mi
workingDir: /home/jenkins
env:
- name: JNLP_MAX_HEAP_UPPER_BOUND_MB
value: 64
#App under test
- name: app-users
image: 172.30.1.1:5000/myproject/app-users:latest
resources:
limits:
memory: 512Mi
env:
- name: SPRING_PROFILES_ACTIVE
value: k8sit
- name: SPRING_CLOUD_KUBERNETES_ENABLED
value: false
#DB
- name: mariadb
image: registry.access.redhat.com/rhscl/mariadb-102-rhel7:1
resources:
limits:
memory: 256Mi
env:
- name: MYSQL_USER
value: myuser
- name: MYSQL_PASSWORD
value: mypassword
- name: MYSQL_DATABASE
value: testdb
- name: MYSQL_ROOT_PASSWORD
value: secret
readinessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 5
#AMQ
- name: amq
image: registry.access.redhat.com/jboss-amq-6/amq63-openshift:1.3
resources:
limits:
memory: 256Mi
env:
- name: AMQ_USER
value: test
- name: AMQ_PASSWORD
value: secret
readinessProbe:
tcpSocket:
port: 61616
initialDelaySeconds: 5
#External API Third party (provided by mockserver)
- name: mockserver
image: jamesdbloom/mockserver:mockserver-5.3.0
resources:
limits:
memory: 256Mi
env:
- name: LOG_LEVEL
value: INFO
- name: JVM_OPTIONS
value: -Xmx128m
readinessProbe:
tcpSocket:
port: 1080
initialDelaySeconds: 5
'''
}
}
environment {
//These env vars are used the tests to send message to users.in queue
AMQ_USER = 'test'
AMQ_PASSWORD = 'secret'
}
steps {
dir ("integration-test") {
container('mariadb') {
//requires mysql
sh 'sql/setup.sh'
}
// Default container 'jnlp'
// this script requires curl and python.
sh 'mockserver/setup.sh'
//Run the tests.
//Somehow simply "mvn ..." doesn't work here
sh '/bin/bash -c "mvn -s ../configuration/settings.xml -B clean test"'
}
}
post {
always {
junit testResults: 'integration-test/target/surefire-reports/*.xml', allowEmptyResults: true
}
}
}
}
}
You can’t perform that action at this time.