Skip to content

Commit

Permalink
source update
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun123 committed Oct 10, 2024
1 parent 712aa21 commit f95aa23
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 26 deletions.
41 changes: 28 additions & 13 deletions bin/main/jenkins/kubernetes_helm_install_pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,34 @@ pipeline {
environment {
PATH = "${env.HOME}/bin:${env.PATH}"
HELM_INSTALLED = false
KUBECTL_INSTALLED = false
}
stages {
stage('Install kubectl and Helm') {
stage('Check and Install kubectl and Helm') {
steps {
script {
// Install kubectl
sh '''
if ! command -v kubectl &> /dev/null; then
// Check and install kubectl
if (sh(script: "command -v kubectl", returnStatus: true) != 0) {
sh '''
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mkdir -p $HOME/bin
mv kubectl $HOME/bin/
fi
kubectl version --client
'''
'''
env.KUBECTL_INSTALLED = true
}
sh "kubectl version --client"
// Install Helm (if not already installed)
sh '''
if ! command -v helm &> /dev/null; then
// Check and install Helm
if (sh(script: "command -v helm", returnStatus: true) != 0) {
sh '''
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
fi
helm version
'''
'''
env.HELM_INSTALLED = true
}
sh "helm version"
}
}
}
Expand Down Expand Up @@ -193,6 +197,17 @@ pipeline {
always {
sh "rm -f ${WORKSPACE}/kubeconfig"
echo "Removed kubeconfig file"
script {
if (env.KUBECTL_INSTALLED == 'true') {
sh "rm -f $HOME/bin/kubectl"
echo "Removed kubectl"
}
if (env.HELM_INSTALLED == 'true') {
sh "rm -f /usr/local/bin/helm"
echo "Removed Helm"
}
}
}
success {
echo "Helm charts installation and verification completed successfully!"
Expand Down
15 changes: 15 additions & 0 deletions bin/main/jenkins/vm_application_install_pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ echo ==========================================================================
}
}
}
post {
always {
echo '>>>>>POST: Cleaning up PEM file'
script {
if (env.PEM_FILE_PATH) {
echo "Deleting PEM file: ${env.PEM_FILE_PATH}"
sh "rm -f ${env.PEM_FILE_PATH}"
echo "PEM file deleted successfully"
} else {
echo "No PEM file to delete"
}
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions bin/main/jenkins/vm_application_uninstall_pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ echo ==========================================================================
}
}
}
post {
always {
echo '>>>>>POST: Cleaning up PEM file'
script {
if (env.PEM_FILE_PATH) {
echo "Deleting PEM file: ${env.PEM_FILE_PATH}"
sh "rm -f ${env.PEM_FILE_PATH}"
echo "PEM file deleted successfully"
} else {
echo "No PEM file to delete"
}
}
}
}
}
]]>
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand All @@ -10,5 +12,6 @@
@NoArgsConstructor
@AllArgsConstructor
public class K8sClusterResponse {
@JsonProperty("K8sClusterInfo")
private List<K8sClusterDto> k8sClusterInfo;
}
41 changes: 28 additions & 13 deletions src/main/resources/jenkins/kubernetes_helm_install_pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,34 @@ pipeline {
environment {
PATH = "${env.HOME}/bin:${env.PATH}"
HELM_INSTALLED = false
KUBECTL_INSTALLED = false
}
stages {
stage('Install kubectl and Helm') {
stage('Check and Install kubectl and Helm') {
steps {
script {
// Install kubectl
sh '''
if ! command -v kubectl &> /dev/null; then
// Check and install kubectl
if (sh(script: "command -v kubectl", returnStatus: true) != 0) {
sh '''
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mkdir -p $HOME/bin
mv kubectl $HOME/bin/
fi
kubectl version --client
'''
'''
env.KUBECTL_INSTALLED = true
}
sh "kubectl version --client"
// Install Helm (if not already installed)
sh '''
if ! command -v helm &> /dev/null; then
// Check and install Helm
if (sh(script: "command -v helm", returnStatus: true) != 0) {
sh '''
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
fi
helm version
'''
'''
env.HELM_INSTALLED = true
}
sh "helm version"
}
}
}
Expand Down Expand Up @@ -193,6 +197,17 @@ pipeline {
always {
sh "rm -f ${WORKSPACE}/kubeconfig"
echo "Removed kubeconfig file"
script {
if (env.KUBECTL_INSTALLED == 'true') {
sh "rm -f $HOME/bin/kubectl"
echo "Removed kubectl"
}
if (env.HELM_INSTALLED == 'true') {
sh "rm -f /usr/local/bin/helm"
echo "Removed Helm"
}
}
}
success {
echo "Helm charts installation and verification completed successfully!"
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/jenkins/vm_application_install_pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ echo ==========================================================================
}
}
}
post {
always {
echo '>>>>>POST: Cleaning up PEM file'
script {
if (env.PEM_FILE_PATH) {
echo "Deleting PEM file: ${env.PEM_FILE_PATH}"
sh "rm -f ${env.PEM_FILE_PATH}"
echo "PEM file deleted successfully"
} else {
echo "No PEM file to delete"
}
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/jenkins/vm_application_uninstall_pipeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ echo ==========================================================================
}
}
}
post {
always {
echo '>>>>>POST: Cleaning up PEM file'
script {
if (env.PEM_FILE_PATH) {
echo "Deleting PEM file: ${env.PEM_FILE_PATH}"
sh "rm -f ${env.PEM_FILE_PATH}"
echo "PEM file deleted successfully"
} else {
echo "No PEM file to delete"
}
}
}
}
}
]]>
</script>
Expand Down

0 comments on commit f95aa23

Please sign in to comment.