Skip to content

Instantly share code, notes, and snippets.

@BigBadBassMan
Forked from jskarpe/Jenkins-php-pipeline
Last active October 18, 2021 13:24
Show Gist options
  • Save BigBadBassMan/afd8b43b6bbfeb9f6e7eeaebf0a17a7e to your computer and use it in GitHub Desktop.
Save BigBadBassMan/afd8b43b6bbfeb9f6e7eeaebf0a17a7e to your computer and use it in GitHub Desktop.
pipeline {
agent any
stages {
stage('Prepare') {
steps {
parallel(
"Composer": {
sh 'composer update'
},
"Clean/Prepare": {
sh 'rm -rf build/api'
sh 'rm -rf build/coverage'
sh 'rm -rf build/logs'
sh 'rm -rf build/pdepend'
sh 'rm -rf build/phpdox'
sh 'mkdir build/api'
sh 'mkdir build/coverage'
sh 'mkdir build/logs'
sh 'mkdir build/pdepend'
sh 'mkdir build/phpdox'
}
)
}
}
stage('PHP Syntax check') { steps { sh 'vendor/bin/parallel-lint --exclude vendor/ .' } }
stage('Build') { steps { sh 'ant db-load' } }
stage('Test'){
steps {
sh 'vendor/bin/phpunit -c phpunit.xml.dist'
}
post {
success {
publishHTML(allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'build/coverage', reportFiles: 'index.html', reportName: 'PHPUnit coverage report', reportTitles: 'Code Coverage')
junit 'build/logs/junit.xml'
}
}
}
stage('Checkstyle') {
steps {
sh 'vendor/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=PSR2 --extensions=php --ignore=autoload.php --runtime-set ignore_warnings_in_exit 1 --runtime-set ignore_errors_on_exit 1 src/ tests/'
}
post {
success {
checkstyle(pattern: 'build/logs/checkstyle.xml')
}
}
}
stage('Lines of Code') { steps { sh 'vendor/bin/phploc --count-tests --exclude vendor/ --log-csv build/logs/phploc.csv --log-xml build/logs/phploc.xml .' } }
stage('Copy paste detection') {
steps {
sh 'vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml --exclude vendor src tests'
}
post {
success {
dry(pattern: 'build/logs/pmd-cpd.xml')
}
}
}
stage('Mess detection') {
steps {
sh 'vendor/bin/phpmd src xml build/phpmd.xml --reportfile build/logs/pmd.xml'
}
post {
success {
pmd(pattern: 'build/logs/pmd.xml')
}
}
}
stage('Software metrics') { steps { sh 'vendor/bin/pdepend --jdepend-xml=build/logs/jdepend.xml --jdepend-chart=build/pdepend/dependencies.svg --overview-pyramid=build/pdepend/overview-pyramid.svg src' } }
stage('Generate documentation') {
steps { sh 'vendor/bin/phpdox -f build/phpdox.xml' }
post {
success {
archiveArtifacts(artifacts: 'build/api/**', fingerprint: true)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment