56 lines
1.6 KiB
Groovy
56 lines
1.6 KiB
Groovy
import com.example.DockerBuilder
|
|
|
|
def call(String appName, String helmChartPath, String helmRepoName,String helmChartVersion, Boolean useCustomDocker, Boolean useInsecureRegistry) {
|
|
def dockerBuilder = new DockerBuilder()
|
|
def containerName = useCustomDocker ? 'custom-docker' : 'docker'
|
|
|
|
stage('Make jar') {
|
|
script {
|
|
buildJar(true)
|
|
}
|
|
}
|
|
stage('Package helm chart') {
|
|
script {
|
|
makeHelmChart("${helmChartPath}/${appName}")
|
|
}
|
|
}
|
|
stage('Upload helm chart') {
|
|
script {
|
|
uploadHelmChart("${appName}-${helmChartVersion}.tgz", env.NEXUS_URL, "admin", env.NEXUS_PASS)
|
|
}
|
|
}
|
|
stage('Docker build & push') {
|
|
container(containerName) {
|
|
script {
|
|
dockerBuilder.dockerBuildAndPush(
|
|
env.NEXUS_DOCKER_URL,
|
|
appName,
|
|
"./Dockerfile",
|
|
"target",
|
|
"admin",
|
|
env.NEXUS_DOCKER_PASS,
|
|
useInsecureRegistry
|
|
)
|
|
}
|
|
}
|
|
}
|
|
stage('Add Helm Repo') {
|
|
script {
|
|
addHelmRepo(helmRepoName, env.NEXUS_URL)
|
|
}
|
|
}
|
|
stage('Deploy Helm Chart') {
|
|
script {
|
|
deployHelm(
|
|
appName,
|
|
helmRepoName,
|
|
appName,
|
|
helmChartVersion,
|
|
env.KUBERNETES_API,
|
|
env.KUBERNETES_TOKEN,
|
|
["app.image": "localhost:31050/my-docker-repo/${appName}:latest", "app.ports.http": 8090, "app.secret": "nexus-secret"]
|
|
)
|
|
}
|
|
}
|
|
}
|