Files
k8s-cluster/code/sample-nodejs-app/Jenkinsfile
2026-04-17 09:15:51 +07:00

68 lines
1.5 KiB
Groovy

pipeline {
agent any
environment {
APP_NAME = 'sample-nodejs-app'
DOCKER_IMAGE = "test-cicd/${APP_NAME}:${env.BUILD_NUMBER}"
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Install Dependencies') {
steps {
dir('code/sample-nodejs-app') {
sh 'npm install'
}
}
}
stage('Test') {
steps {
dir('code/sample-nodejs-app') {
sh 'npm test'
}
}
}
stage('Build Docker Image') {
steps {
dir('code/sample-nodejs-app') {
sh "docker build -t ${APP_NAME}:latest ."
}
}
}
stage('Push to Registry') {
steps {
echo 'Pushing image to registry...'
// sh "docker tag ${APP_NAME}:latest ${DOCKER_IMAGE}"
// sh "docker push ${DOCKER_IMAGE}"
}
}
stage('Deploy to K8s') {
steps {
echo 'Deploying to Kubernetes...'
// sh "kubectl set image deployment/${APP_NAME} ${APP_NAME}=${DOCKER_IMAGE}"
}
}
}
post {
always {
cleanWs()
}
success {
echo 'Pipeline completed successfully!'
}
failure {
echo 'Pipeline failed!'
}
}
}