Skip to content

Commit

Permalink
updated Jenkinsfile for Enterprise use case
Browse files Browse the repository at this point in the history
  • Loading branch information
Amits64 committed Aug 20, 2024
1 parent c374710 commit a854a5b
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ pipeline {
stage('Deploying Container to Kubernetes') {
steps {
script {
sh 'helm version'
dir('crud-app') {
sh 'helm version'

def releaseExists = sh(returnStatus: true, script: "helm ls --kubeconfig ${kubeConfigPath} | grep -q ${image}") == 0
def releaseExists = sh(returnStatus: true, script: "helm ls --kubeconfig ${kubeConfigPath} | grep -q ${image}") == 0

if (releaseExists) {
echo "Existing Helm release found. Deleting release: ${image}"
sh "helm delete ${image} --kubeconfig ${kubeConfigPath}"
} else {
echo "No existing Helm release found for ${image}. Proceeding with installation."
}
if (releaseExists) {
echo "Existing Helm release found. Deleting release: ${image}"
sh "helm delete ${image} --kubeconfig ${kubeConfigPath}"
} else {
echo "No existing Helm release found for ${image}. Proceeding with installation."
}

sh """
helm upgrade --install ${image} ./ \
--kubeconfig ${kubeConfigPath} \
--set appimage=${registry}/${image}:${tag} \
--namespace ${params.NAMESPACE}
"""
sh """
helm upgrade --install ${image} ./ \
--kubeconfig ${kubeConfigPath} \
--set appimage=${registry}/${image}:${tag} \
--namespace ${params.NAMESPACE}
"""
}
}
}
}
Expand Down

0 comments on commit a854a5b

Please sign in to comment.