-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline_helm_install
64 lines (64 loc) · 2.19 KB
/
pipeline_helm_install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
pipeline {
agent {
label 'slave' // Usa lo slave Jenkins configurato
}
environment {
GIT_REPO = 'https://github.com/lucacis8/formazione_sou_k8s.git' // Repository Git corretto
CHART_PATH = 'charts' // Percorso della cartella del chart
NAMESPACE = 'formazione-sou' // Namespace Kubernetes
KUBECONFIG = '/var/jenkins_home/.kube/config' // Imposta il percorso del kubeconfig
}
stages {
stage('Clona repo da Git') {
steps {
git branch: 'main', url: "${GIT_REPO}" // Clona il branch main del repository
}
}
stage('Test kubectl connection') {
steps {
script {
// Imposta il contesto kubectl manualmente
sh 'kubectl config use-context minikube'
sh 'kubectl config current-context' // Verifica che il contesto sia stato impostato
sh 'kubectl get nodes' // Verifica che i nodi siano raggiungibili
}
}
}
stage('Check kubectl permissions') {
steps {
script {
// Verifica se l'utente ha i permessi per creare deploy in Kubernetes
sh 'kubectl auth can-i create deployments --namespace ${NAMESPACE}'
}
}
}
stage('Lint Helm charts') {
steps {
script {
try {
// Esegui linting sui chart
sh 'helm lint ./charts'
} catch (Exception e) {
// Gestisci l'errore, continuando con l'installazione
echo "Helm lint failed, but continuing with installation."
}
}
}
}
stage('Esegui helm install') {
steps {
script {
sh """
helm upgrade --install formazione-sou ./${CHART_PATH} \
--namespace ${NAMESPACE}
"""
}
}
}
}
post {
always {
echo 'Pipeline completata'
}
}
}