Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace2 #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline {
environment {
registry = "Jyoti-Hariwal/counter-app"
registryCredential = 'dockerhub'
KUBECONFIG="$JENKINS_HOME/.kube/config1"
}
agent any
stages {
stage('Building image') {
steps{
sh "printenv"

sh "docker build -t jyoti26/counter-app:$BUILD_ID-$BRANCH_NAME ."
//sh "docker run -dp 80:80 jyoti26/counter-app:$BUILD_ID-$BRANCH_NAME"
sh "docker push jyoti26/counter-app:$BUILD_ID-$BRANCH_NAME"
}
}
stage('Creating Deployment') {
steps {

sh '''#!/bin/bash

if [[ $GIT_BRANCH == "namespace2" ]]
then
kubectl set image deployment/jyoti nginx=jyoti26/counter-app:$BUILD_ID-$BRANCH_NAME -n $BRANCH_NAME
elif [[ $GIT_BRANCH == "master" ]]
then
kubectl set image deployment/jyoti nginx=jyoti26/counter-app:$BUILD_ID-$BRANCH_NAME -n namespace1
fi
'''
}
}

stage('') {
steps{
sh '''

kubectl get svc -n $BRANCH_NAME
'''
}
}
}
}