-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
49 lines (44 loc) · 1.26 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
pipeline {
agent any
tools {
maven 'maven-3.9.9'
}
environment {
DOCKERHUB_CREDENTIALS = credentials ('docker-hub-credentials')
}
stages {
stage('Checkout Code') {
steps {
script {
checkout([
$class: 'GitSCM',
branches: [[name: "*/master"]],
userRemoteConfigs: [[url: 'https://github.com/chetan2967/code']]
])
}
}
}
stage('Clean and Install') {
steps {
sh 'mvn clean install'
}
}
stage('Build Docker Image') {
steps {
script {
// Build the Docker image
sh "docker build -t my-java-app ."
}
}
}
stage('Push to Docker Hub') {
steps {
script {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
sh 'docker push my-java-app:latest'
sh 'docker logout'
}
}
}
}
}