-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
51 lines (39 loc) · 1.24 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
50
51
node {
def app
def image_name
def image_tag
def container_name="nginx"
def dockerhub=""
stage('Clone repository'){
checkout scm
}
stage('Build Docker image'){
image_name="liijuun/nginx"
image_tag="1.${BUILD_NUMBER}"
docker.build("${image_name}:${image_tag}")
}
stage('Test Docker image'){
sh 'echo "Test Passed"'
}
stage('Publish Docker image'){
docker.withRegistry('https://index.docker.io/v1/', 'DockerHubCredential'){
sh "docker push ${image_name}:${image_tag}"
}
sh 'echo "image published"'
}
stage('Deploy on Kubernetes'){
//sh "docker container rm -f ${container_name}"
//sh "docker run --name ${container_name} -d -p 9001:80 ${image_name}:${image_tag}"
sh 'echo "Deploy docker image on Kubernetes"'
sh "sed -i \'s/DYNAMICVERSION/${image_tag}/\' nginx-deployment-service.yaml"
kubernetesDeploy(kubeconfigId: 'kubernetesConfig',
configs: 'nginx-deployment-service.yaml',
enableConfigSubstitution: false,
secretNamespace: 'nginx',
secretName: 'nginx',
dockerCredentials: [
[credentialsId: 'DockerHubCredential']
]
)
}
}