forked from zaffar-maqbool/farmly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
53 lines (48 loc) · 1.42 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
pipeline {
agent any
tools{
jdk 'jdk17'
}
environment {
COMPOSE_FILE = 'docker-compose.yml'
SONARQUBE_CREDENTIALS = 'Sonar-token' // Update with your SonarQube credentials ID
SCANNER_HOME=tool 'sonar-scanner'
}
stages {
stage('Verify Docker Access') {
steps {
script {
// Verify Docker access
sh 'docker ps'
}
}
}
stage('Build and Deploy with Docker Compose') {
steps {
script {
// Deploy using docker-compose
sh "docker-compose -f ${env.COMPOSE_FILE} up -d --build --remove-orphans"
}
}
}
stage("Sonarqube Analysis "){
steps{
withSonarQubeEnv('sonar-server') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=farmy \
-Dsonar.projectKey=farmy '''
}
}
}
}
post {
always {
// Send Slack notification after every build
slackSend(
channel: '#devops',
color: '#FF0000',
message: "Find Status of Pipeline: ${currentBuild.currentResult} ${env.JOB_NAME} ${env.BUILD_NUMBER} ${BUILD_URL}",
tokenCredentialId: 'slack-webhook'
)
}
}
}