Created
July 5, 2019 01:46
-
-
Save havenokarma/31a43b330742e4fc434dba9a754ad0c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.SimpleDateFormat | |
node { | |
def commitHash = "" | |
def dateFormat = new SimpleDateFormat("YYYYmmdd") | |
def timeFormat = new SimpleDateFormat("HHMMSS") | |
def date = new Date() | |
def mavenVersion = "" | |
stage('Checkout scm') { | |
commitHash = checkout(scm).GIT_COMMIT | |
} | |
stage('Build frontend') { | |
dir('frontend') { | |
docker.image('node:12-alpine').inside { | |
sh 'npm install' | |
sh 'node_modules/.bin/ng build --prod' | |
} | |
docker.withRegistry('https://registry.sensei.ap.aws.griddynamics.net/') { | |
def frontImage = docker.build "frontend:1.0-" + dateFormat.format(date) \ | |
+ "-" + timeFormat.format(date) + "-" + BRANCH_NAME \ | |
+ "-" + commitHash.take(6) | |
frontImage.push('latest') | |
} | |
} | |
} | |
stage('Build back-end') { | |
dir('backend') { | |
docker.image('maven:3.6-jdk-8').inside { | |
sh 'mvn -B clean package -DskipTests' | |
mavenVersion = sh returnStdout: true, | |
script: '''mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate \ | |
-Dexpression=project.version -q -DforceStdout''' | |
} | |
// Groovy script security alert :( | |
//timeFormat.setTimeZone(TimeZone.getTimeZone("Europe/Saratov")) | |
docker.withRegistry('https://registry.sensei.ap.aws.griddynamics.net/') { | |
def backImage = docker.build "backend:" + mavenVersion + "-" + dateFormat.format(date) \ | |
+ "-" + timeFormat.format(date) + "-" + BRANCH_NAME \ | |
+ "-" + commitHash.take(6) | |
backImage.push('latest') | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment