Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
def artifact="deployments/launcher/target/*-skinny.tar.gz"
def img_build_hook = null

pipeline {
agent { label 'maven' }
stages {
Expand All @@ -7,24 +10,65 @@ pipeline {
}
}
stage('Build') {
steps {
sh 'mvn -B -V clean verify'
}
}
stage('Function Test') {
when {
expression { env.CHANGE_ID != null } // Pull request
}
steps {
sh 'mvn -B -V clean verify -Prun-its -Pci'
sh 'mvn -B -V verify -Prun-its -Pci'
}
}
stage('Deploy') {
when { branch 'master' }
steps {
echo "Deploy"
sh 'mvn help:effective-settings -B -V clean deploy -e -s ~/sonatype/settings.xml'
sh 'mvn help:effective-settings -B -V deploy -e -s ~/sonatype/settings.xml'
}
}
}
post {
success {
archiveArtifacts artifacts: 'deployments/launcher/target/*-skinny.tar.gz', fingerprint: true
stage('Archive') {
steps {
echo "Archive"
archiveArtifacts artifacts: "$artifact", fingerprint: true
}
}
stage('Check Image Build Hook') {
when {
expression { env.IMG_BUILD_HOOKS != null }
}
steps {
echo "Check Image Build Hook"
script {
def jsonObj = readJSON text: env.IMG_BUILD_HOOKS
if (env.GIT_URL in jsonObj) {
img_build_hook = jsonObj[env.GIT_URL]
}
}
}
}
stage('Build & Push Image') {
when {
allOf {
expression { img_build_hook != null }
expression { env.CHANGE_ID == null } // Not pull request
}
}
steps {
script {
echo "Build docker image"
def artifact_file = sh(script: "ls $artifact", returnStdout: true)?.trim()
def tarball_url = "${BUILD_URL}artifact/$artifact_file"
sh """cat <<EOF > payload_file.yaml
env:
- name: "tarball_url"
value: "${tarball_url}"
EOF"""
sh "curl -H 'Content-Type: application/yaml' --data-binary @payload_file.yaml -k -X POST ${img_build_hook}"
}
}
}
}
}