forked from felipemeriga/DevOps-Example
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathJenkinsfile
More file actions
47 lines (38 loc) · 1.52 KB
/
Jenkinsfile
File metadata and controls
47 lines (38 loc) · 1.52 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
node {
// reference to maven
// ** NOTE: This 'maven-3.5.2' Maven tool must be configured in the Jenkins Global Configuration.
def mvnHome = tool 'maven-3.5.2'
// holds reference to docker image
def dockerImage
// ip address of the docker private repository(nexus)
def dockerImageTag = "devopsexample${env.BUILD_NUMBER}"
stage('Clone Repo') { // for display purposes
// Get some code from a GitHub repository
git 'https://github.com/vikas4cloud/DevOps-Example.git'
// Get the Maven tool.
// ** NOTE: This 'maven-3.5.2' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'maven-3.5.2'
}
stage('Build Project') {
// build project via maven
sh "'${mvnHome}/bin/mvn' clean install"
}
stage('Build Docker Image') {
// build docker image
dockerImage = docker.build("devopsexample:${env.BUILD_NUMBER}")
}
stage('Deploy Docker Image and login'){
echo "Docker Image Tag Name: ${dockerImageTag}"
sh "docker images"
sh "docker login -u vickeyyvickey -p Hello@123" // put PWD
}
stage('Docker push'){
// docker images | awk '{print $3}' | awk 'NR==2'
// sh "docker images | awk '{print $3}' | awk 'NR==2'"
//sh echo "Enter the docker lattest imageID"
//sh "read imageid"
sh "docker tag 90cc3c109088 vickeyyvickey/myapplication" //must change your name and tag no
sh "docker push vickeyyvickey/myapplication"
}
}