-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (55 loc) · 2.62 KB
/
Jenkinsfile
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
65
pipeline {
agent any
stages {
stage ('Build Image') {
steps {
checkout scmGit(branches: [[name: '*/dev']], extensions: [], userRemoteConfigs: [[credentialsId: 'github-sagitta-credentials', url: 'https://github.com/5agitta/apps-service-template.git']])
script {
sh "java -version"
sh "./gradlew bootBuildImage --info"
}
}
}
stage ('Push Docker Image') {
steps {
script {
def username = sh(
script: './gradlew properties | grep -w "registryUsername" | awk -F ": " \'{print $2}\' | awk \'{$1=$1};1\' | tr -d "\\n"',
returnStdout: true,
)
def projectName = sh(
script: './gradlew properties | grep -w "name" | awk -F ": " \'{print $2}\' | awk \'{$1=$1};1\' | tr -d "\\n"',
returnStdout: true,
)
def version = sh(
script: './gradlew properties | grep -w "version" | awk -F ": " \'{print $2}\' | awk \'{$1=$1};1\' | tr -d "\\n"',
returnStdout: true,
)
// Push the Docker image to the registry
sh "docker push $username/$projectName:$version"
}
}
}
stage ('Rollout Deployment') {
steps {
script {
def username = sh(
script: './gradlew properties | grep -w "registryUsername" | awk -F ": " \'{print $2}\' | awk \'{$1=$1};1\' | tr -d "\\n"',
returnStdout: true,
)
def projectName = sh(
script: './gradlew properties | grep -w "name" | awk -F ": " \'{print $2}\' | awk \'{$1=$1};1\' | tr -d "\\n"',
returnStdout: true,
)
def version = sh(
script: './gradlew properties | grep -w "version" | awk -F ": " \'{print $2}\' | awk \'{$1=$1};1\' | tr -d "\\n"',
returnStdout: true,
)
// Deployment
sh "KUBECONFIG=/home/kubeconfig kubectl get pods --namespace dev"
sh "KUBECONFIG=/home/kubeconfig helm upgrade $projectName --namespace dev -f values-dev.yaml oci://registry-1.docker.io/5agitta/sagitta-chart"
}
}
}
}
}