Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!groovy
- /**
- * Requires tool definitions for nodejs, jdk, maven, and ant
- * Requires config files .npmrc and maven-settings.xml
- */
- node() {
- // checkout clean code
- stage("checkout") {
- checkout scm
- sh "git clean -fdx"
- }
- // setup tools and env
- stage("setup" ) {
- def nodejs = tool 'nodejs-6.x'
- def java = tool 'jdk8'
- def maven = tool 'maven-3.3'
- def ant = tool 'ant-1.9'
- env.JAVA_HOME = "${java}"
- env.PATH="${java}/bin:${maven}/bin:${ant}/bin:${nodejs}/bin:${env.PATH}"
- configFileProvider([configFile(fileId: '.npmrc', targetLocation: '.npmrc')]) {}
- }
- dir("app") {
- // install dependencies
- stage("install" ) {
- sh "npm install"
- }
- // run tests
- stage("test" ) {
- def container;
- try {
- container = docker.image('postgres').run("-P -e POSTGRES_PASSWORD=changeit")
- def port = container.port(5432).split(":")[1];
- // container takes a few seconds to start up
- retry(5) {
- sleep 1
- sh "db__port=${port} NODE_ENV=test npm run migrate"
- }
- sh "db__port=${port} npm test"
- } finally {
- if (container) {
- container.stop();
- }
- }
- }
- // package code
- stage("package") {
- sh "npm run archive"
- }
- }
- dir("installer") {
- // build installer part
- stage("build installer") {
- configFileProvider([configFile(fileId: 'maven-settings.xml', variable: "MAVEN_SETTINGS")]) {
- sh "mvn -s ${MAVEN_SETTINGS} install"
- }
- }
- stage("archive") {
- archiveArtifacts artifacts: "target/**/*.zip,target/**/*.md5"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement