Skip to content

Commit d9606e9

Browse files
committed
Refactor: Improve deployment process
1 parent 507a914 commit d9606e9

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

Jenkinsfile

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pipeline {
44
nodejs 'node23'
55
}
66
stages {
7-
stage('Install') {
7+
stage('Install Dependencies') {
88
steps {
99
script {
1010
echo "--------------------------------------------------"
@@ -52,15 +52,44 @@ pipeline {
5252
}
5353
}
5454
}
55-
stage('Deploy') {
55+
stage('Containerize') {
5656
steps {
5757
script {
58-
sh 'echo "Deploying..."'
59-
// Deploy to the server
60-
kubeDeploy(configs: 'kubeconfig', namespace: 'default', resourceType: 'deployment', resourceNames: 'myapp', replicas: 3)
58+
sh 'echo "Containerizing..."'
59+
sh 'docker build -t app .'
60+
// Create manifest file for container
61+
sh '''cat <<EOF > app.yaml
62+
apiVersion: apps/v1
63+
kind: Deployment
64+
metadata:
65+
name: app
66+
spec:
67+
replicas: 1
68+
selector:
69+
matchLabels:
70+
app: app
71+
template:
72+
metadata:
73+
labels:
74+
app: app
75+
spec:
76+
containers:
77+
- name: app
78+
image: app
79+
ports:
80+
- containerPort: 3000
81+
EOF'''
6182
}
6283
}
6384
}
85+
stage('Deploy Container') {
86+
withKubeConfig([credentialsId: 'kubeconfig', serverUrl: 'https://kubernetes.default.svc.cluster.local']) {
87+
sh 'echo "Deploying Container..."'
88+
sh 'kubectl apply -f app.yaml'
89+
sh 'kubectl get pods --watch'
90+
sh 'until kubectl get pods | grep app | grep -m 1 "Running"; do sleep 5; done'
91+
}
92+
}
6493
stage('Notify') {
6594
steps {
6695
script {

0 commit comments

Comments
 (0)