-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
47 lines (39 loc) · 1.03 KB
/
Jenkinsfile
File metadata and controls
47 lines (39 loc) · 1.03 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
pipeline {
agent any
environment {
DOCKERHUB_CREDENTIALS = 'docker2'
IMAGE_NAME = 'poorvik07/new_docker_image'
}
stages {
stage('Build Java Application') {
steps {
bat 'javac HelloWorld.java'
}
}
stage('Run Java Program') {
steps {
bat 'java HelloWorld'
}
}
stage('Build Docker Image') {
steps {
bat 'docker build -t %IMAGE_NAME%:latest .'
}
}
stage('Login to DockerHub') {
steps {
withCredentials([usernamePassword(
credentialsId: 'docker2',
usernameVariable: 'USER',
passwordVariable: 'PASS')]) {
bat 'echo %PASS%| docker login -u %USER% --password-stdin'
}
}
}
stage('Push Docker Image') {
steps {
bat 'docker push %IMAGE_NAME%:latest'
}
}
}
}