-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
83 lines (72 loc) · 2.44 KB
/
Jenkinsfile
File metadata and controls
83 lines (72 loc) · 2.44 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def eksCluster="dev-eks-cluster"
def region="ap-south-1"
def artifactName = "${env.BUILD_NUMBER}"
pipeline {
tools {
maven 'Maven3'
}
agent any
/* environment {
NEW_IMAGE_NAME = "srirammani/k8s_images:dev-${artifactName}"
YAML_FILE_PATH = "sample-webapp.yml" */
stages {
stage('Git Clone') {
steps {
script {
git 'https://github.com/Bujji369/sriram-web.git'
}
}
}
stage('compile') {
steps {
sh 'mvn -B -DskipTests clean compile'
}
}
stage('Build') {
steps {
sh "mvn -B -e package -DskipTests"
}
}
stage('Docker Image Build') {
steps {
sh "docker build -t srirammani/k8s_images:qa-${artifactName} ."
}
}
stage('Image upload DockerHub') {
steps {
script {
withCredentials([string(credentialsId: 'dockerhubpwd', variable: 'dockerhubpwd')]) {
sh "docker login -u srirammani -p ${dockerhubpwd}"
sh "sleep 20s"
}
sh "docker push srirammani/k8s_images:dev-${artifactName}"
}
}
}
/* stage('Chage Image in yaml') {
steps {
script {
sh 'git config --global user.email "medichirlabujji@gmail.com"'
sh 'git config --global user.name "Bujji369"'
// Update the .yaml file with the new image name
sh "sed -i 's#image:srirammani/k8s_images:*#image: $NEW_IMAGE_NAME#g' $YAML_FILE_PATH"
// Commit and push the changes (assuming you have Git configured)
sh "git add $YAML_FILE_PATH"
sh "git commit -m 'updated the image in YAML file'"
sh "git push origin master"
}
}
} */
stage('Integrate Jenkins with EKS Cluster and Deploy App') {
steps {
withAWS(credentials: 'aws_Credentials_Id', region: '${region}') {
script {
sh "cat test.yml"
sh "aws eks update-kubeconfig --region ap-south-1 --name dev-eks-cluster"
sh "kubectl apply -f test.yml"
}
}
}
}
}
}