1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- @Library('jenkins-library@master') _
- def Label = "promo-build-${UUID.randomUUID().toString()}"
- pipeline {
- options {
- buildDiscarder logRotator(numToKeepStr: '10')
- disableConcurrentBuilds()
- }
- agent {
- kubernetes {
- label Label
- yaml libraryResource('promoPodDefinition.yaml')
- }
- }
- environment {
- CLOUD='cloud-it-k8s'
- DOCKER_IMAGE='iru/promo'
- CHART_PATH='helm/info'
- NAMESPACE='info'
- HELM_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/k8s.git'
- APP_GIT_URL='ssh://gitolite@git.alfatell.ru:2223/web-registration-cloud.git'
- JENKINS_MAIL='jenkins.dev@sdsys.ru'
- DOCKER_REGISTRY='jcr.infoclinica.ru'
- CHART_NAME=''
- APP_DIR=''
- HELM_DIR=''
- TAG=''
- }
- parameters {
- string(
- name: "branch",
- defaultValue: "release",
- description: "Which branch to use"
- )
- string(
- name: "mailto",
- defaultValue: "admin@sdsys.ru",
- description: "Email which has to be notified."
- )
- }
- stages {
- stage("Prepare to build") {
- steps {
- script {
- echo "Pull ${APP_GIT_URL}"
- gitOps.clone(APP_GIT_URL)
- APP_DIR = dirOps.calculateDir(APP_GIT_URL)
- echo "CheckOut ${branch}"
- gitOps.checkout(APP_DIR, branch)
- echo "Save Version"
- dir(APP_DIR) {
- sh 'echo $(git log -p -1 --pretty=format:"%h"|head -n1) > version'
- }
- }
- }
- }
- stage("Build APP") {
- steps {
- script {
- echo "Build customer-api"
- dir("${APP_DIR}/customer-api") {
- buildOps.maven()
- }
- echo "Build Promo"
- dir("${APP_DIR}/promo") {
- buildOps.gradle()
- }
- }
- }
- }
- stage("Build Image") {
- steps {
- script {
- sh "cp ${APP_DIR}/promo/build/libs/promo-0.0.1-SNAPSHOT.war ."
- sh "cp ${APP_DIR}/version ."
- REGISTRY = DOCKER_REGISTRY + "/" + DOCKER_IMAGE
- COMMIT = sh(script: "cat version 2> /dev/null", returnStdout: true).trim()
- TAG = "${COMMIT}-${BUILD_NUMBER}"
- echo "Build Image with Kaniko with parameters"
- echo "Repository: ${REGISTRY}"
- echo "Tag: ${TAG}"
- k8sBuildImage.kaniko(REGISTRY, TAG)
- }
- }
- }
- }
- }
|