blob: aebb21776d7b566f428ef1737f5623148def3b27 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pipeline {
agent { label 'ubuntu' }
environment {
CASS_HOME = "${WORKSPACE}/temp/apache-cassandra-2.1.20"
ES_HOME = "${WORKSPACE}/temp/elasticsearch-1.7.5"
}
tools {
maven 'Maven 3 (latest)'
jdk 'JDK 1.8 (latest)'
}
options {
timeout(time: 120, unit: 'MINUTES')
}
stages {
stage ('Initialize') {
steps {
sh '''
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
'''
emailext (
subject: "STARTED : UG Build Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """UG Build Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' has been kicked off \nCheck output at '${env.BUILD_URL}'""",
recipientProviders: [[$class: 'RequesterRecipientProvider'], [$class: 'DevelopersRecipientProvider']]
)
}
}
stage ('Build Usergrid-Java') {
steps {
git 'https://github.com/apache/usergrid-java.git'
sh '''
mvn clean install -DskipTests=true
'''
}
}
stage ('Setup C*, ES and Code') {
steps {
sh '''
mkdir -p $WORKSPACE/temp
cd $WORKSPACE/temp
rm -rf *
wget http://archive.apache.org/dist/cassandra/2.1.20/apache-cassandra-2.1.20-bin.tar.gz
tar -xvf apache-cassandra-2.1.20-bin.tar.gz
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.tar.gz
tar -xvf elasticsearch-1.7.5.tar.gz
echo "Setup C* and ES."
'''
git 'https://github.com/apache/usergrid.git'
}
}
stage ('Build Usergrid Stack Grp 1') {
steps {
startDBs()
sh '''
mvn clean install -f stack/build-tools/pom.xml
mvn clean install -f stack/config/pom.xml
mvn clean install -f stack/corepersistence/pom.xml
mvn clean install -f stack/core/pom.xml
'''
stopDBs()
}
}
stage ('Build Usergrid Stack Grp 2') {
steps {
startDBs()
sh '''
mvn clean install -f stack/services/pom.xml
'''
stopDBs()
}
}
stage ('Build Usergrid Stack Grp 3') {
steps {
startDBs()
sh '''
mvn clean install -f stack/rest/pom.xml
'''
stopDBs()
}
}
stage ('Build Usergrid Stack Grp 4') {
steps {
startDBs()
sh '''
mvn clean install -f stack/tools/pom.xml
mvn clean install -f stack/query-validator/pom.xml
'''
stopDBs()
}
}
}
post {
always {
echo 'End of pipeline'
junit 'stack/**/surefire-reports/*.xml'
sh 'ps -ef | grep cassandra'
sh 'ps -ef | grep elastic'
deleteDir() /*clean up our workspace */
}
success {
echo 'Usergrid build and tests succeeded'
emailext (
subject: "SUCCESS : UG Build Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """UG Build Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' has completed SUCCESSFULLY \nCheck output at '${env.BUILD_URL}'""",
recipientProviders: [[$class: 'RequesterRecipientProvider'], [$class: 'DevelopersRecipientProvider']]
)
}
failure {
echo 'Usergrid build and/or tests failed'
emailext (
subject: "FAILURE : UG Build Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """UG Build Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' has FAILED \nCheck output at '${env.BUILD_URL}'""",
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider'], [$class: 'DevelopersRecipientProvider']]
)
}
}
}
def stopDBs() {
sh '''
echo "Stopping C* and ES ..."
$CASS_HOME/bin/nodetool status
$CASS_HOME/bin/nodetool drain
kill -9 $(pgrep -if 'cassandra')
kill -9 $(pgrep -if 'elastic')
ps -ef | grep -i cassandra
ps -ef | grep -i elastic
rm -rf $CASS_HOME/data/*
rm -rf $CASS_HOME/logs/*
rm -rf $ES_HOME/data/*
rm -rf $ES_HOME/logs/*
echo "Stopped C* and ES."
'''
}
def startDBs() {
sh '''
echo "Starting C* and ES ..."
$CASS_HOME/bin/cassandra
$ES_HOME/bin/elasticsearch -d
echo "Started C* and ES. Waiting 1 min before starting tests ..."
sleep 60
'''
}
def resetState() {
stopDBs()
startDBs()
}