First iteration to implement jenkins shared libraries
This commit is contained in:
68
Jenkinsfile
vendored
68
Jenkinsfile
vendored
@@ -1,3 +1,5 @@
|
||||
@Library('my-shared-library@main') _
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
kubernetes {
|
||||
@@ -73,72 +75,52 @@ spec:
|
||||
stages{
|
||||
stage('Make jar') {
|
||||
steps {
|
||||
container('maven') {
|
||||
sh 'mvn install -DskipTests'
|
||||
script {
|
||||
buildJar(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Make chart') {
|
||||
stage('Package helm chart') {
|
||||
steps {
|
||||
container('helm') {
|
||||
sh 'helm package example-app-helm-chart/example-app'
|
||||
script {
|
||||
makeHelmChart("example-app-helm-chart/example-app")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Upload chart') {
|
||||
stage('Upload helm chart') {
|
||||
steps {
|
||||
container('maven') {
|
||||
sh 'curl -u admin:$NEXUS_PASS --upload-file example-app-1.0.0-SNAPSHOT.tgz $NEXUS_URL'
|
||||
uploadHelmChart("example-app-1.0.0-SNAPSHOT.tgz", "$NEXUS_URL", "admin", "$NEXUS_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker in Docker start') {
|
||||
stage('Docker build & push') {
|
||||
steps {
|
||||
container('docker') {
|
||||
sh 'dockerd --insecure-registry http://$NEXUS_DOCKER_URL &'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker build in Docker') {
|
||||
steps {
|
||||
container('docker') {
|
||||
sh 'docker build -t example-app -f ./Dockerfile target'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker repo login') {
|
||||
steps {
|
||||
container('docker') {
|
||||
sh 'docker login http://$NEXUS_DOCKER_URL -u admin -p $NEXUS_DOCKER_PASS'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker image tag') {
|
||||
steps {
|
||||
container('docker') {
|
||||
sh 'docker tag example-app $NEXUS_DOCKER_URL/my-docker-repo/example-app:latest'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker image push') {
|
||||
steps {
|
||||
container('docker') {
|
||||
sh 'docker push $NEXUS_DOCKER_URL/my-docker-repo/example-app:latest'
|
||||
script {
|
||||
dockerBuildAndPush("$NEXUS_DOCKER_URL", "example-app", "./Dockerfile", "target", "admin", "$NEXUS_DOCKER_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Add Helm Repo') {
|
||||
steps {
|
||||
container('helm') {
|
||||
sh 'helm repo add my-helm-repo $NEXUS_URL'
|
||||
sh 'helm repo update'
|
||||
script {
|
||||
addHelmRepo("my-helm-repo", "$NEXUS_URL")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Deploy Helm Chart') {
|
||||
steps {
|
||||
container('helm') {
|
||||
sh 'helm install example-app my-helm-repo/example-app --kube-apiserver $KUBERNETES_API --kube-token $KUBERNETES_TOKEN --kube-insecure-skip-tls-verify --version 1.0.0-SNAPSHOT --set app.ports.http=8090 --set app.image=localhost:31050/my-docker-repo/example-app:latest --set imagePullSecrets[0]=nexus-secret'
|
||||
script {
|
||||
deployHelm(
|
||||
"example-app",
|
||||
"my-helm-repo",
|
||||
"example-app",
|
||||
"1.0.0-SNAPSHOT",
|
||||
"$KUBERNETES_API",
|
||||
"$KUBERNETES_TOKEN",
|
||||
"localhost:31050/my-docker-repo/example-app:latest",
|
||||
["app.ports.http": 8090, "imagePullSecrets[0]": "nexus-secret"]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user