69 lines
2.3 KiB
Groovy
69 lines
2.3 KiB
Groovy
pipeline {
|
|
agent {
|
|
node {
|
|
label 'jenkins-slave'
|
|
}
|
|
}
|
|
environment {
|
|
ESXI_PASS = credentials('VI_PASSWORD')
|
|
QINDEL_PASS = credentials('jenkins-user-slave-password')
|
|
PATH = "/home/qindel/bin/ovftool:${env.PATH}"
|
|
}
|
|
stages {
|
|
stage('Prepare environment') {
|
|
steps {
|
|
dir ('tests/API-dhcp') {
|
|
echo "Install vagrant plugin"
|
|
sh 'vagrant plugin install vagrant-vmware-esxi'
|
|
echo "Deploy API server for DHCP with Vagrant"
|
|
sh 'vagrant up --provider=vmware_esxi --provision'
|
|
}
|
|
}
|
|
}
|
|
stage('Check Installation') {
|
|
steps {
|
|
dir ('tests/API-dhcp') {
|
|
echo "Get IP of API server for DHCP with Vagrant"
|
|
sh '''
|
|
set -e
|
|
new_ip=$(vagrant ssh -c "hostname -I" | tr -d '\r')
|
|
echo "$QINDEL_PASS" | sudo -S bash -c "echo '$new_ip api-test' >> /etc/hosts"
|
|
echo "IP: $new_ip"
|
|
curl -f -L -X 'GET' -H 'accept: application/json' "http://api-test/opengnsys3/rest/dhcp/subnets/"
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
stage ('Run API tests') {
|
|
steps {
|
|
echo 'Running API tests'
|
|
}
|
|
}
|
|
stage('Clean up') {
|
|
steps {
|
|
dir ('tests/API-dhcp') {
|
|
echo "Destroy API server for DHCP with Vagrant"
|
|
// sh 'vagrant destroy -f'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
script {
|
|
def commiterEmail = sh(script: 'git log -1 --pretty=format:%ae', returnStdout: true).trim()
|
|
emailext(
|
|
to: "${committerEmail}",
|
|
subject: "Jenkins Job Completed: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
|
|
body: """
|
|
El job '${env.JOB_NAME}' con número de build ${env.BUILD_NUMBER} ha finalizado.
|
|
|
|
Estado: ${currentBuild.currentResult}
|
|
|
|
Revisa los detalles del build en: ${env.BUILD_URL}
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
}
|