|
| 1 | +@Library('jenkins.shared.library') _ |
| 2 | + |
| 3 | +pipeline { |
| 4 | + agent { |
| 5 | + label 'ubuntu_docker_label' |
| 6 | + } |
| 7 | + environment { |
| 8 | + HELM_IMAGE = "infoblox/helm:3" |
| 9 | + REGISTRY = "core-harbor-prod.sdp.infoblox.com" |
| 10 | + VERSION = sh(script: "git describe --always --long --tags | sed s/^prometheus-kafka-adapter-//", returnStdout: true).trim() |
| 11 | + TAG = "${env.VERSION}-j${env.BUILD_NUMBER}" |
| 12 | + } |
| 13 | + stages { |
| 14 | + stage("Build Image") { |
| 15 | + steps { |
| 16 | + sh 'docker build . -t prometheus-kafka-adapter:$TAG' |
| 17 | + } |
| 18 | + } |
| 19 | + stage("Push Image") { |
| 20 | + when { |
| 21 | + anyOf { |
| 22 | + branch 'master' |
| 23 | + branch 'jenkinsfile' |
| 24 | + } |
| 25 | + } |
| 26 | + steps { |
| 27 | + script { |
| 28 | + signDockerImage('prometheus-kafka-adapter', env.TAG, 'infoblox') |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + stage("Package Chart") { |
| 33 | + steps { |
| 34 | + dir("chart") { |
| 35 | + sh ''' |
| 36 | + sed -i "s!repository: .*!repository: $REGISTRY/infoblox/prometheus-kafka-adapter!g" prometheus-kafka-adapter/values.yaml |
| 37 | + ''' |
| 38 | + withAWS(credentials: "CICD_HELM", region: "us-east-1") { |
| 39 | + sh ''' |
| 40 | + docker run --rm \ |
| 41 | + -e AWS_REGION \ |
| 42 | + -e AWS_ACCESS_KEY_ID \ |
| 43 | + -e AWS_SECRET_ACCESS_KEY \ |
| 44 | + -v $(pwd):/pkg \ |
| 45 | + $HELM_IMAGE package /pkg/prometheus-kafka-adapter --app-version $TAG --version $TAG -d /pkg |
| 46 | + ''' |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + stage("Push Chart") { |
| 52 | + steps { |
| 53 | + withAWS(credentials: "CICD_HELM", region: " us-east-1") { |
| 54 | + sh ''' |
| 55 | + chart_file=prometheus-kafka-adapter-$TAG.tgz |
| 56 | + docker run --rm \ |
| 57 | + -e AWS_REGION \ |
| 58 | + -e AWS_ACCESS_KEY_ID \ |
| 59 | + -e AWS_SECRET_ACCESS_KEY \ |
| 60 | + -v $(pwd)/chart:/pkg \ |
| 61 | + $HELM_IMAGE s3 push /pkg/$chart_file infobloxcto |
| 62 | + echo "repo=infobloxcto" > build.properties |
| 63 | + echo "chart=$chart_file" >> build.properties |
| 64 | + echo "messageFormat=s3-artifact" >> build.properties |
| 65 | + echo "customFormat=true" >> build.properties |
| 66 | + ''' |
| 67 | + } |
| 68 | + archiveArtifacts artifacts: 'build.properties' |
| 69 | + archiveArtifacts artifacts: 'chart/*.tgz' |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + post { |
| 74 | + success { |
| 75 | + finalizeBuild() |
| 76 | + } |
| 77 | + } |
| 78 | +} |
0 commit comments