Skip to content

Instantly share code, notes, and snippets.

@NoodlesNZ
Created April 11, 2017 23:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NoodlesNZ/6f8f4b288faf774ba71671f0182f2dbd to your computer and use it in GitHub Desktop.
Save NoodlesNZ/6f8f4b288faf774ba71671f0182f2dbd to your computer and use it in GitHub Desktop.
PHP Pipeline
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
sh 'rm -rf build/{logs,pdepend}'
sh 'mkdir -p build/{logs,pdepend}'
sh '/usr/local/bin/composer install'
}
}
stage('Code analysis') {
steps {
parallel (
lint: {
sh './vendor/bin/parallel-lint -s --exclude vendor/ .'
},
phpmd: {
sh '/usr/bin/phpmd public_html xml build/phpmd.xml --reportfile build/logs/pmd.xml --suffixes php --ignore-violations-on-exit'
},
phpcs: {
sh '/usr/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/phpcs.xml --extensions=php --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 public_html tests'
}
)
}
post {
success {
step(
[
$class: 'PmdPublisher',
canComputeNew: false,
defaultEncoding: '',
pattern: 'build/logs/pmd.xml',
healthy: '70',
unHealthy: '999'
]
)
step(
[
$class: 'CheckStylePublisher',
canComputeNew: false,
defaultEncoding: '',
healthy: '100',
pattern: 'build/logs/checkstyle.xml',
unHealthy: '999'
]
)
}
}
}
stage('Unit tests') {
steps {
sh './vendor/phpunit/phpunit/phpunit --configuration phpunit-no-coverage-unit-only.xml --no-coverage --log-junit build/logs/junit.xml'
}
post {
success {
step(
[
$class: 'XUnitBuilder',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [[
$class: 'FailedThreshold',
failureNewThreshold: '',
failureThreshold: '',
unstableNewThreshold: '',
unstableThreshold: ''
],
[
$class: 'SkippedThreshold',
failureNewThreshold: '',
failureThreshold: '',
unstableNewThreshold: '',
unstableThreshold: ''
]],
tools: [[
$class: 'PHPUnitJunitHudsonTestType',
deleteOutputFiles: true,
failIfNotNew: true,
pattern: 'build/logs/junit.xml',
skipNoTestFiles: false,
stopProcessingIfError: true
]]
]
)
}
}
}
}
post {
success {
slackSend(channel: '#deploy', color: 'good', message: "${env.JOB_BASE_NAME} - #${env.BUILD_ID} Success after ${currentBuild.durationString.replaceAll(' and counting', '')} (<${env.BUILD_URL}|Open>)")
}
failure {
slackSend(channel: '#deploy', color: 'danger', message: "${env.JOB_BASE_NAME} - #${env.BUILD_ID} Failure after ${currentBuild.durationString.replaceAll(' and counting', '')} (<${env.BUILD_URL}|Open>)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment