proxy-mocketbank/Jenkinsfile
Alexey 656addf6cb
Move to registry; Bump java to v11 (#45)
* Move to registry; Bump java to v11
2019-03-22 15:59:46 +03:00

50 lines
1.7 KiB
Groovy

#!groovy
build('proxy-mocketbank', 'java-maven') {
checkoutRepo()
def serviceName = env.REPO_NAME
def mvnArgs = '-DjvmArgs="-Xmx256m"'
// Run mvn and generate docker file
runStage('Maven package') {
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
def mvn_command_arguments = ' --batch-mode --settings $SETTINGS_XML -P ci ' +
" -Dgit.branch=${env.BRANCH_NAME} " +
" ${mvnArgs}"
if (env.BRANCH_NAME == 'master') {
sh 'mvn deploy' + mvn_command_arguments
} else {
sh 'mvn package' + mvn_command_arguments
}
}
}
def serviceImage;
def imgShortName = 'rbkmoney/' + "${serviceName}" + ':' + '$COMMIT_ID';
getCommitId()
runStage('Build Service image') {
docker.withRegistry('https://dr2.rbkmoney.com/v2/', 'jenkins_harbor') {
serviceImage = docker.build(imgShortName, '-f ./target/Dockerfile ./target')
}
}
try {
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic')) {
runStage('Push Service image') {
docker.withRegistry('https://dr2.rbkmoney.com/v2/', 'jenkins_harbor') {
serviceImage.push();
}
// Push under 'withRegistry' generates 2d record with 'long name' in local docker registry.
// Untag the long-name
sh "docker rmi dr2.rbkmoney.com/${imgShortName}"
}
}
}
finally {
runStage('Remove local image') {
// Remove the image to keep Jenkins runner clean.
sh "docker rmi ${imgShortName}"
}
}
}