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

source update #73

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
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
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
Loading