Skip to content

Instantly share code, notes, and snippets.

@allebb
Created Feb 15, 2020
Embed
What would you like to do?
A Jenkinsfile demonstating a build pipeline in Jenkins using Docker Agents for multiple PHP version testing.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git(url: 'https://github.com/allebb/jenkdock-demo.git', branch: 'master')
}
}
stage('Test') {
parallel {
stage('PHP 5.6') {
agent {
docker {
image 'allebb/phptestrunner-56:latest'
args '-u root:sudo'
}
}
steps {
echo 'Running PHP 5.6 tests...'
sh 'php -v'
echo 'Installing Composer'
sh 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer'
echo 'Installing project composer dependencies...'
sh 'cd $WORKSPACE && composer install --no-progress'
echo 'Running PHPUnit tests...'
sh 'php $WORKSPACE/vendor/bin/phpunit --coverage-html $WORKSPACE/report/clover --coverage-clover $WORKSPACE/report/clover.xml --log-junit $WORKSPACE/report/junit.xml'
sh 'chmod -R a+w $PWD && chmod -R a+w $WORKSPACE'
junit 'report/*.xml'
}
}
stage('PHP 7.3') {
agent {
docker {
image 'allebb/phptestrunner-73:latest'
args '-u root:sudo'
}
}
steps {
echo 'Running PHP 7.3 tests...'
sh 'php -v'
echo 'Installing Composer'
sh 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer'
echo 'Installing project composer dependencies...'
sh 'cd $WORKSPACE && composer install --no-progress'
echo 'Running PHPUnit tests...'
sh 'php $WORKSPACE/vendor/bin/phpunit --coverage-html $WORKSPACE/report/clover --coverage-clover $WORKSPACE/report/clover.xml --log-junit $WORKSPACE/report/junit.xml'
sh 'chmod -R a+w $PWD && chmod -R a+w $WORKSPACE'
junit 'report/*.xml'
}
}
stage('PHP 7.4') {
agent {
docker {
image 'allebb/phptestrunner-74:latest'
args '-u root:sudo'
}
}
steps {
echo 'Running PHP 7.4 tests...'
sh 'php -v'
echo 'Installing Composer'
sh 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer'
echo 'Installing project composer dependencies...'
sh 'cd $WORKSPACE && composer install --no-progress'
echo 'Running PHPUnit tests...'
sh 'php $WORKSPACE/vendor/bin/phpunit --coverage-html $WORKSPACE/report/clover --coverage-clover $WORKSPACE/report/clover.xml --log-junit $WORKSPACE/report/junit.xml'
sh 'chmod -R a+w $PWD && chmod -R a+w $WORKSPACE'
junit 'report/*.xml'
}
}
}
}
stage('Release') {
steps {
echo 'Ready to release etc.'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment