forked from ersanjaysah/installation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline-of-jenkinsfile
67 lines (57 loc) · 2.1 KB
/
pipeline-of-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
pipeline {
agent any
environment{
SCANNER_HOME= tool 'sonar-scanner'
}
stages {
stage('git clone') {
steps {
git branch: 'main', changelog: false, poll: false, url: 'https://github.com/ersanjaysah/Ekart.git'
}
}
stage('COMPILE') {
steps {
sh "mvn clean compile -DskipTests=true"
}
}
stage('Sonarqube') {
steps {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.url=http://65.1.106.77:9000/ -Dsonar.login=squ_5cfa93e6de01bffe93630962a30e894ed236efb1 -Dsonar.projectName=Ekart \
-Dsonar.java.binaries=. \
-Dsonar.projectKey=Ekart '''
}
}
stage('OWASP Scan') {
steps {
dependencyCheck additionalArguments: '--scan ./ ', odcInstallation: 'dp-check'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('mvn install') {
steps {
sh "mvn clean package -DskipTests=true"
}
}
stage("docker images"){
steps{
sh "docker build -t ekartimage ."
}
}
stage("push to docker hub"){
steps{
echo "pushing the image to docker hub"
withCredentials([usernamePassword(credentialsId:"dockerhub", passwordVariable:"dockerHubPass", usernameVariable:"dockerHubUser")]){
sh "docker tag ekartimage ${env.dockerHubUser}/ekartimage:latest"
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPass}"
sh "docker push ${env.dockerHubUser}/ekartimage:latest"
}
}
}
stage("deployed in docker-compose"){
steps{
echo "deployed the image into a container with docker-compose"
sh "docker-compose down && docker-compose up -d"
}
}
}
}