-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
79 lines (79 loc) · 2.77 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pipeline {
agent {
docker {
image 'serversideup/php:8.4-cli'
args '--user root'
}
}
options {
ansiColor('xterm')
}
stages {
stage('installing required packages') {
steps {
sh '''
install-php-extensions intl gd xsl pcov
cp .env.example .env && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
composer config --no-plugins allow-plugins.phpstan/extension-installer true && \
composer install --no-interaction --prefer-dist && \
php artisan key:generate
'''
}
}
stage('php test') {
steps {
sh 'php artisan test -p --log-junit coverage/tests.xml --coverage-clover coverage/coverage.xml --colors=never'
}
post {
always {
archiveArtifacts artifacts: 'coverage/tests.xml, coverage/coverage.xml', allowEmptyArchive: true
}
}
}
stage('Code Analysis') {
agent {
docker {
image 'sonarsource/sonar-scanner-cli:latest'
args '--user root'
}
}
environment {
scannerHome = tool 'sonar'
}
steps {
script {
sh "cp -r /var/jenkins_home/workspace/github-integration/commit-pipeline/coverage ${WORKSPACE}"
withSonarQubeEnv('sonar') {
sh "${scannerHome}/bin/sonar-scanner \
-Dsonar.projectKey=cronos \
-Dsonar.projectName=cronos \
-Dsonar.sources=. \
-Dsonar.projectVersion=1.0 \
-Dsonar.tests=tests \
-Dsonar.exclusions=vendor/**,node_modules/**,tests/**,coverage/**,coverage_report/** \
-Dsonar.php.coverage.reportPaths=coverage/coverage.xml \
-Dsonar.php.tests.reportPath=coverage/tests.xml"
}
}
}
post {
always {
cleanWs()
}
}
}
stage('quality gate') {
steps {
script {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
echo "Quality Gate failed: ${qg.status}"
echo "Full Quality Gate details: ${qg}"
error "Pipeline failed due to quality gate failure: ${qg.status}"
}
}
}
}
}
}