forked from sudheer76R/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsfile
More file actions
60 lines (49 loc) · 1.79 KB
/
jenkinsfile
File metadata and controls
60 lines (49 loc) · 1.79 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
pipeline {
agent any
environment {
registry = '224498103667.dkr.ecr.ap-south-1.amazonaws.com/ci-cd'
}
stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/main']], doGenerateSubmoduleConfigurations: false, extensions: [], userRemoteConfigs: [[url: 'https://github.com/anusha1908/java-example.git']]])
}
}
stage('Building image') {
steps{
script {
dockerImage = docker.build registry
}
}
}
stage('Pushing to ECR') {
steps{
script {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
sh 'aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 224498103667.dkr.ecr.ap-south-1.amazonaws.com'
sh 'docker push 224498103667.dkr.ecr.ap-south-1.amazonaws.com/ci-cd:latest'
}
}
}
}
stage('test') {
steps {
echo " testing..."
}
}
stage('Docker Run') {
steps{
script {
sh 'docker run -d -p 8083:8080 --rm --name Container3 224498103667.dkr.ecr.ap-south-1.amazonaws.com/ci-cd:latest'
}
}
}
stage('Deploying to Kubernetes') {
steps{
withKubeConfig([credentialsId: 'k8s', serverUrl: 'https://172.31.33.161:6443']) {
sh "kubectl apply -f app.yaml -n dev"
}
}
}
}
}