Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
115 lines (115 loc) · 3.48 KB
/
Copy pathJenkinsfile
File metadata and controls
115 lines (115 loc) · 3.48 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
pipeline {
agent {
label 'node01'
}
environment {
DB_ENGINE = 'postgres'
POSTGRES_SERVER = 'localhost'
}
parameters {
booleanParam defaultValue: false, description: 'Do you want to run Sonarqube test?', name: 'enableSonarqubeScan'
}
tools {
nodejs 'nodejs'
}
stages {
stage('Install dependencies') {
steps {
script {
container = docker.image('postgres').run('-e POSTGRES_USER=mealie -e POSTGRES_PASSWORD=mealie -e POSTGRES_DB=mealie --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -p 5432:5432')
}
sh '''
sudo apt update
sudo apt install python3 make libsasl2-dev libldap2-dev libssl-dev tesseract-ocr-all -y
curl -sSL https://install.python-poetry.org | python3 -
export PATH=/var/lib/jenkins/.local/bin:$PATH
poetry env use python3.10
poetry install
npm i --global yarn
cd frontend
yarn
'''
}
}
stage('Tests') {
steps {
sh '''
rm -f *-report.xml
make clean-test
cd frontend
yarn test
cd ..
export PATH=/var/lib/jenkins/.local/bin:$PATH
make backend-test
'''
snykSecurity(
snykInstallation: 'snyk',
snykTokenId: 'snyk',
failOnIssues: false,
additionalArguments: '--all-projects'
)
}
post {
always {
junit 'test-report.xml'
}
}
}
stage('SonarQube Analysis') {
tools {
nodejs 'nodejs'
}
when { expression { params.enableSonarqubeScan == true } }
steps {
script {
scannerHome = tool 'SonarScanner';
withSonarQubeEnv('sonar') {
sh 'npm i postcss-sass --save'
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
stage('Build Docker') {
environment {
user = "msl0"
registryCredentialsId = "dockerhub"
}
steps {
script {
dockerImageFrontend = docker.build(user +"/mealie-front" + ":$BUILD_NUMBER", 'frontend')
dockerImageBackend = docker.build(user +"/mealie-backend" + ":$BUILD_NUMBER", '--target production')
docker.withRegistry('', registryCredentialsId) {
dockerImageFrontend.push()
dockerImageBackend.push()
}
}
}
}
stage('Run DEV') {
steps {
make docker-dev
}
post {
always {
input 'Is the application working properly?'
}
}
}
stage('Run PROD') {
when {
branch 'main'
}
steps {
make docker-prod
}
}
}
post {
always {
script {
container.stop()
}
}
}
}