-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile
31 lines (30 loc) · 1.13 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
pipeline {
agent any
stages {
stage('CI') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
git url:'https://github.com/Aly-Ghazal/nodejs-app-deployment-from-jenkins', branch:'main',
credentialsId: 'Github-user'
sh """
docker login -u ${USERNAME} -p ${PASSWORD}
cd /var/jenkins_home/workspace/Deploy-App-in-K8s/jenkins_nodejs_example
docker build . -f dockerfile --network host -t alyghazal22/nodejs-app:v2.0
docker push alyghazal22/nodejs-app:v2.0
"""
}
}
}
stage('CD') {
steps {
sh '''
cd /var/jenkins_home/workspace/Deploy-App-in-K8s/K8s-app-files
kubectl apply -f NameSpace.yml
kubectl apply -f Deployment.yml
kubectl apply -f Service.yml
kubectl get svc -n app-ns
'''
}
}
}
}