-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
65 lines (57 loc) · 2.23 KB
/
Jenkinsfile
File metadata and controls
65 lines (57 loc) · 2.23 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
pipeline {
agent any
stages {
stage('Checkout GitHub repo') {
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/bjnandi/python-flask-postgresql-crud-application.git']])
}
}
stage('SonarQube Analysis') {
environment {
scannerHome = tool 'S_Scanner_python_app'; // SonarQube Scanner Neme
}
steps {
withSonarQubeEnv(credentialsId: 'sonarqube', installationName: 'sonarqube_server') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
stage('Quality Gate') {
steps {
script {
// Wait for SonarQube Quality Gate result and proceed only if it passes
def qualityGate = waitForQualityGate() // Wait for the quality gate result
if (qualityGate.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qualityGate.status}"
}
}
}
}
stage('Build and Tag Docker Image') {
steps {
script {
sh 'docker build . -t bjnandi/python-crud-app:v1.0.${BUILD_NUMBER}'
//sh 'docker tag python-app bjnandi/python-crud-app:v1.0.${BUILD_NUMBER}'
}
}
}
stage('Push the Docker Image to DockerHub') {
steps {
script {
withCredentials([string(credentialsId: 'docker_hub', variable: 'docker_hub')]) {
sh 'echo "${docker_hub}" | docker login -u bjnandi --password-stdin'
}
sh 'docker push bjnandi/python-crud-app:v1.0.${BUILD_NUMBER}'
}
}
}
stage('Trigger Manifest Update') {
steps {
script {
sh 'echo "triggering update app manifest job"'
}
build job: 'update-app-manifest', parameters: [string(name: 'DOCKERTAG', value: env.BUILD_NUMBER)]
}
}
}
}