Jenkinsfile declarative
| 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 ( | |
| 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' | |
| }, | |
| phploc: { | |
| sh '/usr/bin/phploc --count-tests --log-csv build/logs/phploc.csv --log-xml build/logs/phploc.xml 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: '#bottest', color: 'good', message: "Build succeeded - (<${env.BUILD_URL}|Open>)") | |
| } | |
| failure { | |
| slackSend(channel: '#bottest', color: 'bad', message: "Build failed - (<${env.BUILD_URL}|Open>)") | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment