-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
29 lines (28 loc) · 1.19 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
podTemplate(containers: [
containerTemplate(name: 'podman', image: 'vniks/podman-agent:v1', command: 'cat', privileged: true, user: 'root', ttyEnabled: true),
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:latest', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/run/podman/podman.sock', hostPath: '/run/podman/podman.sock')
]) {
node(POD_LABEL) {
stage('Get a git project') {
git 'https://github.com/vnikhil89/jenkins-pipeline.git'
container('podman') {
stage('Build a docker image and push') {
withCredentials([string(credentialsId: 'dockerhub-pwd', variable: 'dockerhubpwd')]){
sh 'podman login docker.io -u vniks -p ${dockerhubpwd}'
sh 'podman build -t docker.io/vniks/jenkins-pipeline:v1 .'
sh 'podman push docker.io/vniks/jenkins-pipeline:v1'
}
}
}
stage('Deployment') {
container('kubectl') {
sh 'kubectl apply -f hello.yaml'
sh 'kubectl apply -f hello-svc.yaml'
}
}
}
}
}