From 0c1178022bd281a54b95c4b864e95ac9487c6637 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Thu, 11 Feb 2016 16:09:03 -0600 Subject: [PATCH 01/18] added outputs for concourse v0.72 --- ci/tasks/build.yml | 6 ++++++ ci/tasks/prepare-final.yml | 7 +++++++ ci/tasks/prepare-integration.yml | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/ci/tasks/build.yml b/ci/tasks/build.yml index 76b15bd..e2a380d 100644 --- a/ci/tasks/build.yml +++ b/ci/tasks/build.yml @@ -1,7 +1,13 @@ --- platform: linux + image: docker:///java#8 + inputs: - name: pcfdemo + +outputs: + - name: build + run: path: pcfdemo/ci/tasks/build.sh diff --git a/ci/tasks/prepare-final.yml b/ci/tasks/prepare-final.yml index d47b3aa..c2b1b45 100644 --- a/ci/tasks/prepare-final.yml +++ b/ci/tasks/prepare-final.yml @@ -1,10 +1,17 @@ --- platform: linux + image: docker:///java#8 + inputs: - name: pcfdemo - name: candidate-release - name: version + +outputs: + - name: candidate-release + path: . + run: path: pcfdemo/ci/tasks/rename-artifact.sh args: ["-d", "candidate-release", "-v", "version/number"] diff --git a/ci/tasks/prepare-integration.yml b/ci/tasks/prepare-integration.yml index e771ef8..8d76a7d 100644 --- a/ci/tasks/prepare-integration.yml +++ b/ci/tasks/prepare-integration.yml @@ -1,9 +1,16 @@ --- platform: linux + image: docker:///java#8 + inputs: - name: pcfdemo - name: candidate-release + +outputs: + - name: candidate-release + path: . + run: path: pcfdemo/ci/tasks/rename-artifact.sh args: [ "-d", "candidate-release" ] From 1e3ce41337e2255ba802559f8c50f209d796f273 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Fri, 12 Feb 2016 21:27:25 -0600 Subject: [PATCH 02/18] updated maven wrapper --- .mvn/wrapper/maven-wrapper.jar | Bin 49502 -> 49519 bytes mvnw | 13 +- mvnw.cmd | 290 ++++++++++++++++----------------- 3 files changed, 152 insertions(+), 151 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 5fd4d5023f1463b5ba3970e33c460c1eb26d748d..c6feb8bb6f76f2553e266ff8bf8867105154237e 100644 GIT binary patch delta 1017 zcmYk)eJs>*90%|_ocrM}52$MGp!Xf51FO2q{b2}pRZMJyS?^#-{<@JeZSxPO_ynZEz@R&25ak> z(kP0eX($=%EkjE~;Ymh- zI2@9B>23F84mRT6hB+u+;EksbOl!e9l|_{fc=oV{)E+ke6!fSpyzwA!9x~)%vNSePoh~M`k}}+3kGMXULGmYgmPSy&DQ6mh zx#c9_&>8>~ zv<3sOTf_Co*=sp0YHh`E7IEA7X7zm|LB2E^&1d_&`;S8jZMG%D`mgv#!u4yLzQu>c z3h7v#LRJ=&mStzj&B~~Gkp5z#ZM|Gyl|N9I!%G!=UKX>n*%OJ&dmTfKQ`6tMK2(wu`JA=^~xN?hFWVcOl@= zLmpJU!)i|ogfWU-U`&w%2z%pzrrr|3T6rG0p^N|~mEnM6-#MVFPXuiAMFHU|viWWm zIW4z82Ex34J|O8o0nGG!0v2i^kfIJ^YpCn~|6T^9R7YAsvimYkw=eboCk{Ejw9yTd GLh=W5FqZiM delta 1008 zcmYk)c}SCC7y$6ixyy?w;xzJFnmVINW!}duooR)M4v)wykEV8bY>0TIXcS?`icqWps#@qLmtj2V#(c`A0slR1Q9VJkR^Q&-Xs>zO^#iTp7(MBAljg zPGPZF6f3sEXo9Y1#U^IxNi@)(9SbpyRpdsIr5k;LxyiPYu$q}0e-V_SOYx~*#zadGdbIFjwup8(2+SRRN#dh+a ziE@wSwlcezfv`|gMV=ZtDqeaY@5+x_Ctudp)VE7xg1C#+$0JiMJh5qd!9r$+j&2=t z#==q(8vL;E@{h3T!Y0AHe)~v8+?MVY>5yAzkQM#9djH~q{>1FB&&0Q$U%yfHV$p?B zW8CKXYkIb_RzwUk%N=V=3a9kFOY6(VCIva^lfJ&6`gpm+Hs5K|$qmnj`3ld46_bc? zChNY_hvX;QQ}C%U302RW^7k7=iCqaW^-xzPz6wP?(4xSRnKA_;nKBXhs7wa@2wc)l zWJ9#CTME>5mjc#3GT>ehPMVN7x<+1sK&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -set MAVEN_CMD_LINE_ARGS=%* - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% \ No newline at end of file +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% From 682d2daca0d2c4ec0c0bf5f0de6f79679d0708b9 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Fri, 12 Feb 2016 21:58:23 -0600 Subject: [PATCH 03/18] added maven opts and config to pipeline --- ci/pcfdemo-properties-sample.yml | 3 +++ ci/pipeline.yml | 12 +++++++++++- ci/tasks/build.yml | 4 ++++ ci/tasks/integration.yml | 3 +++ ci/tasks/unit.yml | 7 +++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ci/pcfdemo-properties-sample.yml b/ci/pcfdemo-properties-sample.yml index 8925518..46901b6 100644 --- a/ci/pcfdemo-properties-sample.yml +++ b/ci/pcfdemo-properties-sample.yml @@ -1,10 +1,13 @@ github-uri: https://github.com/.../PCF-demo.git +github-branch: master s3-access-key-id: SAMPLEDF99FSWEBF9DW9 s3-secret-access-key: sampleaxfdpiA98FG8u7ahd08Sdgf8AFG8gh8S0F s3-endpoint: s3.amazonaws.com s3-bucket-version: pcfdemo-releases s3-bucket-releases: pcfdemo-releases s3-bucket-release-candidates: pcfdemo-release-candidates +maven-opts: # -Xms256m -Xmx512m +maven-config: # -s path/to/settings.xml cf-api: https://api.local.micropcf.io cf-username: admin cf-password: admin diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 058c350..bb860f1 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -4,7 +4,7 @@ resources: type: git source: uri: {{github-uri}} - branch: master + branch: {{github-branch}} - name: version type: semver @@ -52,6 +52,10 @@ jobs: trigger: true - task: unit file: pcfdemo/ci/tasks/unit.yml + config: + params: &MAVENPARAMS + MAVEN_OPTS: {{maven-opts}} + MAVEN_CONFIG: {{maven-config}} - name: build-artifact serial_groups: [ version ] @@ -63,6 +67,9 @@ jobs: params: { pre: rc } - task: build file: pcfdemo/ci/tasks/build.yml + config: + params: + <<: *MAVENPARAMS - task: prepare-build file: pcfdemo/ci/tasks/prepare-build.yml - put: candidate-release @@ -88,6 +95,9 @@ jobs: path: prepare-integration/pcf-demo.war - task: integration file: pcfdemo/ci/tasks/integration.yml + config: + params: + <<: *MAVENPARAMS - name: ship-it serial_groups: [ version ] diff --git a/ci/tasks/build.yml b/ci/tasks/build.yml index e2a380d..2f3139b 100644 --- a/ci/tasks/build.yml +++ b/ci/tasks/build.yml @@ -3,6 +3,10 @@ platform: linux image: docker:///java#8 +params: + MAVEN_OPTS: + MAVEN_CONFIG: + inputs: - name: pcfdemo diff --git a/ci/tasks/integration.yml b/ci/tasks/integration.yml index 66220c7..07af2ad 100644 --- a/ci/tasks/integration.yml +++ b/ci/tasks/integration.yml @@ -1,7 +1,10 @@ --- platform: linux + image: docker:///java#8 + inputs: - name: pcfdemo + run: path: pcfdemo/ci/tasks/integration.sh diff --git a/ci/tasks/unit.yml b/ci/tasks/unit.yml index 5d1670d..442bf99 100644 --- a/ci/tasks/unit.yml +++ b/ci/tasks/unit.yml @@ -1,7 +1,14 @@ --- platform: linux + image: docker:///java#8 + +params: + MAVEN_OPTS: + MAVEN_CONFIG: + inputs: - name: pcfdemo + run: path: pcfdemo/ci/tasks/unit.sh From 95bfe496105f3e3263eebdd4641e12468160134f Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Fri, 12 Feb 2016 22:03:49 -0600 Subject: [PATCH 04/18] moved build-artifact to output folder --- ci/tasks/build.sh | 3 +++ ci/tasks/prepare-build.yml | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/tasks/build.sh b/ci/tasks/build.sh index a809dbd..0f02b06 100755 --- a/ci/tasks/build.sh +++ b/ci/tasks/build.sh @@ -4,3 +4,6 @@ export MAVEN_BASEDIR=pcfdemo pcfdemo/mvnw --file=pcfdemo/pom.xml clean package + +# Copy war file to concourse output folder +cp pcfdemo/target/*.war build/. diff --git a/ci/tasks/prepare-build.yml b/ci/tasks/prepare-build.yml index d988868..c70c375 100644 --- a/ci/tasks/prepare-build.yml +++ b/ci/tasks/prepare-build.yml @@ -1,10 +1,13 @@ --- platform: linux + image: docker:///java#8 + inputs: - name: pcfdemo - name: build - name: version + run: path: pcfdemo/ci/tasks/rename-artifact.sh - args: [ "-d", "build/pcfdemo/target", "-v", "version/number" ] + args: [ "-d", "build", "-v", "version/number" ] From 04b26270484ad2d35f30dcd7ec49a62e7dd0050a Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 03:14:40 -0600 Subject: [PATCH 05/18] added required output directory --- ci/tasks/prepare-build.yml | 9 +++++- ci/tasks/prepare-final.yml | 9 ++++-- ci/tasks/prepare-integration.yml | 8 +++-- ci/tasks/rename-artifact.sh | 53 ++++++++++++++++++++------------ 4 files changed, 53 insertions(+), 26 deletions(-) diff --git a/ci/tasks/prepare-build.yml b/ci/tasks/prepare-build.yml index c70c375..a6da009 100644 --- a/ci/tasks/prepare-build.yml +++ b/ci/tasks/prepare-build.yml @@ -8,6 +8,13 @@ inputs: - name: build - name: version +outputs: + - name: prepare-build + run: path: pcfdemo/ci/tasks/rename-artifact.sh - args: [ "-d", "build", "-v", "version/number" ] + args: [ + "--input-dir", "build", + "--output-dir", "prepare-build", + "--version-file", "version/number" + ] diff --git a/ci/tasks/prepare-final.yml b/ci/tasks/prepare-final.yml index c2b1b45..89efeec 100644 --- a/ci/tasks/prepare-final.yml +++ b/ci/tasks/prepare-final.yml @@ -9,9 +9,12 @@ inputs: - name: version outputs: - - name: candidate-release - path: . + - name: prepare-final run: path: pcfdemo/ci/tasks/rename-artifact.sh - args: ["-d", "candidate-release", "-v", "version/number"] + args: [ + "--input-dir", "candidate-release", + "--output-dir", "prepare-final", + "--version-file", "version/number" + ] diff --git a/ci/tasks/prepare-integration.yml b/ci/tasks/prepare-integration.yml index 8d76a7d..d13117c 100644 --- a/ci/tasks/prepare-integration.yml +++ b/ci/tasks/prepare-integration.yml @@ -8,9 +8,11 @@ inputs: - name: candidate-release outputs: - - name: candidate-release - path: . + - name: prepare-integration run: path: pcfdemo/ci/tasks/rename-artifact.sh - args: [ "-d", "candidate-release" ] + args: [ + "--input-dir", "candidate-release", + "--output-dir", "prepare-integration", + ] diff --git a/ci/tasks/rename-artifact.sh b/ci/tasks/rename-artifact.sh index 33b264f..98b1505 100755 --- a/ci/tasks/rename-artifact.sh +++ b/ci/tasks/rename-artifact.sh @@ -1,25 +1,40 @@ #!/bin/bash baseName="pcf-demo" -srcDir= -versionFile= - -while getopts "d:v:" opt; do - case $opt in - d) srcDir=$OPTARG - ;; - v) versionFile=$OPTARG - ;; - ?) echo "?=$OPTARG" - ;; + +inputDir= # required +outputDir= # required +versionFile= # optional + +while [ $# -gt 0 ]; do + case $1 in + -i | --input-dir ) + inputDir=$2 + shift + ;; + -o | --output-dir ) + outputDir=$2 + shift + ;; + -v | --version-file ) + versionFile=$2 + shift + ;; + * ) + echo "Unrecognized option: $1" 1>&2 + exit 1 + ;; esac + shift done -shift $((OPTIND - 1)) -echo "srcDir=$srcDir" +if [ ! -d "$inputDir" ]; then + echo "missing input directory!" + exit 1 +fi -if [ ! -d "$srcDir" ]; then - echo "missing source directory!" +if [ ! -d "$outputDir" ]; then + echo "missing output directory!" exit 1 fi @@ -28,9 +43,9 @@ if [ -f "$versionFile" ]; then baseName="${baseName}-${version}" fi -srcWar=`find $srcDir -name '*.war'` -dstWar="${baseName}.war" +inputWar=`find $inputDir -name '*.war'` +outputWar="${outputDir}/${baseName}.war" -echo "Renaming ${srcWar} to ${dstWar}" +echo "Renaming ${inputWar} to ${outputWar}" -cp ${srcWar} ${dstWar} +cp ${inputWar} ${outputWar} From ad81931b88e653731ebdece43bd3ab54aa385877 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 05:38:50 -0600 Subject: [PATCH 06/18] refactored to process manifest.yml for cf integration test deployment --- ci/pcfdemo-properties-sample.yml | 1 + ci/pipeline.yml | 5 +-- ci/tasks/prepare-integration.yml | 10 ++++-- ci/tasks/process-manifest.sh | 58 ++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100755 ci/tasks/process-manifest.sh diff --git a/ci/pcfdemo-properties-sample.yml b/ci/pcfdemo-properties-sample.yml index 46901b6..dffd25d 100644 --- a/ci/pcfdemo-properties-sample.yml +++ b/ci/pcfdemo-properties-sample.yml @@ -13,6 +13,7 @@ cf-username: admin cf-password: admin cf-org: micropcf-org cf-space: micropcf-space +cf-manifest-host: pcfdemo-ci github-private-key: | -----BEGIN RSA PRIVATE KEY----- SamplejjkKiRxGdgR8p5kZJj0AFgdWYa3OT2snIXnN5+/p7j13PSkseUcrAFyokc diff --git a/ci/pipeline.yml b/ci/pipeline.yml index bb860f1..159ecaa 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -89,10 +89,11 @@ jobs: passed: [ build-artifact ] - task: prepare-integration file: pcfdemo/ci/tasks/prepare-integration.yml + params: + CF_MANIFEST_HOST: {{cf-manifest-host}} - put: cf params: - manifest: pcfdemo/manifest.yml - path: prepare-integration/pcf-demo.war + manifest: prepare-integration/manifest.yml - task: integration file: pcfdemo/ci/tasks/integration.yml config: diff --git a/ci/tasks/prepare-integration.yml b/ci/tasks/prepare-integration.yml index d13117c..e84f231 100644 --- a/ci/tasks/prepare-integration.yml +++ b/ci/tasks/prepare-integration.yml @@ -3,6 +3,9 @@ platform: linux image: docker:///java#8 +params: + CF_MANIFEST_HOST: + inputs: - name: pcfdemo - name: candidate-release @@ -11,8 +14,9 @@ outputs: - name: prepare-integration run: - path: pcfdemo/ci/tasks/rename-artifact.sh + path: pcfdemo/ci/tasks/process-manifest.sh args: [ - "--input-dir", "candidate-release", - "--output-dir", "prepare-integration", + --input-manifest, pcfdemo/manifest.yml, + --output-manifest, prepare-integration/manifest.yml, + --path, candidate-release ] diff --git a/ci/tasks/process-manifest.sh b/ci/tasks/process-manifest.sh new file mode 100755 index 0000000..272b4ca --- /dev/null +++ b/ci/tasks/process-manifest.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# required +inputManifest= outputManifest= + +# optional +host=$CF_MANIFEST_HOST path= + +while [ $# -gt 0 ]; do + case $1 in + -i | --input-manifest ) + inputManifest=$2 + shift + ;; + -o | --output-manifest ) + outputManifest=$2 + shift + ;; + -n | --host ) + host=$2 + shift + ;; + -p | --path ) + path=$2 + shift + ;; + * ) + echo "Unrecognized option: $1" 1>&2 + exit 1 + ;; + esac + shift +done + +if [ ! -f "$inputManifest" ]; then + echo "missing input manifest!" + exit 1 +fi + +if [ -z "$outputManifest" ]; then + echo "missing output manifest!" + exit 1 +fi + +cp $inputManifest $outputManifest + +if [ ! -z "$host" ]; then + sed -i "s|host: .*$|host: ${host}|g" $outputManifest +fi + +if [ ! -z "$path" ]; then + if [ -d "$path" ]; then + path=`find $path -name '*.war'` + fi + sed -i -- "s|path: .*$|path: ${path}|g" $outputManifest +fi + +cat $outputManifest From eedb1e40afd913b9b3983eea6512d37911a7deec Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 05:55:59 -0600 Subject: [PATCH 07/18] fixed missing config node --- ci/pipeline.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 159ecaa..56e5cbd 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -89,8 +89,9 @@ jobs: passed: [ build-artifact ] - task: prepare-integration file: pcfdemo/ci/tasks/prepare-integration.yml - params: - CF_MANIFEST_HOST: {{cf-manifest-host}} + config: + params: + CF_MANIFEST_HOST: {{cf-manifest-host}} - put: cf params: manifest: prepare-integration/manifest.yml From 9203a9f2794aaf6e8a7ab961313719a389a0c582 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 05:56:53 -0600 Subject: [PATCH 08/18] debugging: change to parent folder after processing manifest --- ci/tasks/process-manifest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/tasks/process-manifest.sh b/ci/tasks/process-manifest.sh index 272b4ca..4c173b5 100755 --- a/ci/tasks/process-manifest.sh +++ b/ci/tasks/process-manifest.sh @@ -56,3 +56,4 @@ if [ ! -z "$path" ]; then fi cat $outputManifest +cd .. From 53b63040d476507dbf3b1b9365a8b085ad1988fb Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 06:01:13 -0600 Subject: [PATCH 09/18] debugging: change to parent folder after processing manifest --- ci/tasks/process-manifest.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/tasks/process-manifest.sh b/ci/tasks/process-manifest.sh index 4c173b5..5796d03 100755 --- a/ci/tasks/process-manifest.sh +++ b/ci/tasks/process-manifest.sh @@ -52,8 +52,7 @@ if [ ! -z "$path" ]; then if [ -d "$path" ]; then path=`find $path -name '*.war'` fi - sed -i -- "s|path: .*$|path: ${path}|g" $outputManifest + sed -i -- "s|path: .*$|path: ../${path}|g" $outputManifest fi cat $outputManifest -cd .. From 89feedd5c13139e7b2c3f4f64f59176deb4ca7df Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 06:58:29 -0600 Subject: [PATCH 10/18] updated readme and sample properties file --- ci/README.md | 12 ++++++++---- ci/pcfdemo-properties-sample.yml | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/README.md b/ci/README.md index 8e565b3..ea9d759 100644 --- a/ci/README.md +++ b/ci/README.md @@ -9,11 +9,11 @@ The end-to-end scenario is to monitor a Git repository for commits, and when new commits are detected, run its unit tests. If the unit tests pass, the pipeline will then create a new release candidate -artifact with automated versioning, which then will be placed in a S3 bucket. +artifact with automated versioning, which then will be placed in a S3 bucket. From there, the pipeline will run integration tests against the release candidate. -From there, the pipeline will run integration tests against the release candidate, -and if those pass, it will create a final artifact and "ship it" by putting it in -a different S3 bucket. +These tasks comprise the automated continuous integration part of the pipeline. Once +a candidate-release is properly vetted, the "ship-it" task can be manually invoked to +put the final-release version in a different S3 bucket. ## Prerequisites @@ -28,6 +28,10 @@ day trial, or [MicroPCF](https://micropcf.io) to run locally) ## Concourse Setup If you have an existing Concourse CI system setup, skip to the next section. + +> NOTE: The pipeline and scripts used in this project have been tested on Concourse +**v0.72.1**. If you experience any problems, please ensure you are running a current version of Concourse, and remember to `fly sync` ! + Otherwise if you just want to quickly start up Concourse on your local machine you can use the pre-built [Vagrant](https://www.vagrantup.com/) box: diff --git a/ci/pcfdemo-properties-sample.yml b/ci/pcfdemo-properties-sample.yml index dffd25d..5f5b2e3 100644 --- a/ci/pcfdemo-properties-sample.yml +++ b/ci/pcfdemo-properties-sample.yml @@ -1,7 +1,7 @@ github-uri: https://github.com/.../PCF-demo.git github-branch: master -s3-access-key-id: SAMPLEDF99FSWEBF9DW9 -s3-secret-access-key: sampleaxfdpiA98FG8u7ahd08Sdgf8AFG8gh8S0F +s3-access-key-id: SAMPLEDF99FSWEBF9DW9 # AWS or S3 compatible access key id +s3-secret-access-key: sampleaxfdpiA98FG8u7ahd08Sdgf8AFG8gh8S0F # AWS or S3 compatible secret access key s3-endpoint: s3.amazonaws.com s3-bucket-version: pcfdemo-releases s3-bucket-releases: pcfdemo-releases From 2f758a46bfa311b54edb4815fe6202355c20b32f Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 07:00:43 -0600 Subject: [PATCH 11/18] documented ugly hack --- ci/tasks/process-manifest.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/tasks/process-manifest.sh b/ci/tasks/process-manifest.sh index 5796d03..c051f92 100755 --- a/ci/tasks/process-manifest.sh +++ b/ci/tasks/process-manifest.sh @@ -52,6 +52,8 @@ if [ ! -z "$path" ]; then if [ -d "$path" ]; then path=`find $path -name '*.war'` fi + # ugly hack: cf-resource is running in the directory of the last run task, so + # we need to ../ to the parent directory to find the war file. sed -i -- "s|path: .*$|path: ../${path}|g" $outputManifest fi From d05f2308e8c3ab6b10bc9e38c2a890a5a87da999 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 14:20:28 -0600 Subject: [PATCH 12/18] copy war file to prepare-integration output --- ci/tasks/process-manifest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/tasks/process-manifest.sh b/ci/tasks/process-manifest.sh index c051f92..672051e 100755 --- a/ci/tasks/process-manifest.sh +++ b/ci/tasks/process-manifest.sh @@ -52,9 +52,9 @@ if [ ! -z "$path" ]; then if [ -d "$path" ]; then path=`find $path -name '*.war'` fi - # ugly hack: cf-resource is running in the directory of the last run task, so - # we need to ../ to the parent directory to find the war file. - sed -i -- "s|path: .*$|path: ../${path}|g" $outputManifest + outputDir=`dirname $outputManifest` + cp $path $outputDir + sed -i -- "s|path: .*$|path: ${path}|g" $outputManifest fi cat $outputManifest From 859a38f8c1f6dd913bf4c90011246909dfa04cdb Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 15:19:04 -0600 Subject: [PATCH 13/18] refactored prepare-integration to include processed manifest and deployable artifact --- ci/tasks/prepare-integration.sh | 95 ++++++++++++++++++++++++++++++++ ci/tasks/prepare-integration.yml | 10 +++- ci/tasks/process-manifest.sh | 60 -------------------- 3 files changed, 102 insertions(+), 63 deletions(-) create mode 100755 ci/tasks/prepare-integration.sh delete mode 100755 ci/tasks/process-manifest.sh diff --git a/ci/tasks/prepare-integration.sh b/ci/tasks/prepare-integration.sh new file mode 100755 index 0000000..20bd8ee --- /dev/null +++ b/ci/tasks/prepare-integration.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# required +inputDir= outputDir= inputManifest= versionFile= artifactId= packaging= + +# optional +hostname=$CF_MANIFEST_HOST # default to env variable from pipeline + +while [ $# -gt 0 ]; do + case $1 in + -i | --input-dir ) + inputDir=$2 + shift + ;; + -o | --output-dir ) + outputDir=$2 + shift + ;; + -v | --version-file ) + versionFile=$2 + shift + ;; + -f | --input-manifest ) + inputManifest=$2 + shift + ;; + -a | --artifactId ) + artifactId=$2 + shift + ;; + -p | --packaging ) + packaging=$2 + shift + ;; + -n | --hostname ) + hostname=$2 + shift + ;; + * ) + echo "Unrecognized option: $1" 1>&2 + exit 1 + ;; + esac + shift +done + +error_and_exit() { + echo $1 >&2 + exit 1 +} + +if [ ! -d "$inputDir" ]; then + error_and_exit "missing input directory: $inputDir" +fi +if [ ! -d "$outputDir" ]; then + error_and_exit "missing output directory: $outputDir" +fi +if [ ! -f "$versionFile" ]; then + error_and_exit "missing version file: $versionFile" +fi +if [ ! -f "$inputManifest" ]; then + error_and_exit "missing input manifest: $inputManifest" +fi +if [ -z "$artifactId" ]; then + error_and_exit "missing artifactId!" +fi +if [ -z "$packaging" ]; then + error_and_exit "missing packaging!" +fi + +# copy the war file to the output directory +version=`cat $versionFile` +artifactName="${artifactId}-${version}.${packaging}" + +inputArtifact="$inputDir/$artifactName" +outputArtifact="$outputDir/$artifactName" + +if [ ! -f "$inputArtifact" ]; then + error_and_exit "can not find artifact: $inputArtifact" +fi + +cp $inputArtifact $outputArtifact + +# copy the manifest to the output directory and process it +outputManifest=$outputDir/manifest.yml + +cp $inputManifest $outputManifest + +sed -i -- "s|path: .*$|path: $outputArtifact|g" $outputManifest + +if [ ! -z "$hostname" ]; then + sed -i "s|host: .*$|host: ${hostname}|g" $outputManifest +fi + +cat $outputManifest diff --git a/ci/tasks/prepare-integration.yml b/ci/tasks/prepare-integration.yml index e84f231..41dba0f 100644 --- a/ci/tasks/prepare-integration.yml +++ b/ci/tasks/prepare-integration.yml @@ -9,14 +9,18 @@ params: inputs: - name: pcfdemo - name: candidate-release + - name: version outputs: - name: prepare-integration run: - path: pcfdemo/ci/tasks/process-manifest.sh + path: pcfdemo/ci/tasks/prepare-integration.sh args: [ + --input-dir, candidate-release, + --output-dir, prepare-integration, + --version-file, version/number, --input-manifest, pcfdemo/manifest.yml, - --output-manifest, prepare-integration/manifest.yml, - --path, candidate-release + --artifactId, pcf-demo, + --packaging, war ] diff --git a/ci/tasks/process-manifest.sh b/ci/tasks/process-manifest.sh deleted file mode 100755 index 672051e..0000000 --- a/ci/tasks/process-manifest.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -# required -inputManifest= outputManifest= - -# optional -host=$CF_MANIFEST_HOST path= - -while [ $# -gt 0 ]; do - case $1 in - -i | --input-manifest ) - inputManifest=$2 - shift - ;; - -o | --output-manifest ) - outputManifest=$2 - shift - ;; - -n | --host ) - host=$2 - shift - ;; - -p | --path ) - path=$2 - shift - ;; - * ) - echo "Unrecognized option: $1" 1>&2 - exit 1 - ;; - esac - shift -done - -if [ ! -f "$inputManifest" ]; then - echo "missing input manifest!" - exit 1 -fi - -if [ -z "$outputManifest" ]; then - echo "missing output manifest!" - exit 1 -fi - -cp $inputManifest $outputManifest - -if [ ! -z "$host" ]; then - sed -i "s|host: .*$|host: ${host}|g" $outputManifest -fi - -if [ ! -z "$path" ]; then - if [ -d "$path" ]; then - path=`find $path -name '*.war'` - fi - outputDir=`dirname $outputManifest` - cp $path $outputDir - sed -i -- "s|path: .*$|path: ${path}|g" $outputManifest -fi - -cat $outputManifest From a608ec20f38aa68c461273bd446fc18bb30432db Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 15:33:22 -0600 Subject: [PATCH 14/18] removed outputDir from path in manifest (path is relative to manifest) --- ci/tasks/prepare-integration.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/tasks/prepare-integration.sh b/ci/tasks/prepare-integration.sh index 20bd8ee..dca59a3 100755 --- a/ci/tasks/prepare-integration.sh +++ b/ci/tasks/prepare-integration.sh @@ -86,7 +86,8 @@ outputManifest=$outputDir/manifest.yml cp $inputManifest $outputManifest -sed -i -- "s|path: .*$|path: $outputArtifact|g" $outputManifest +# the path in the manifest is always relative to the manifest itself +sed -i -- "s|path: .*$|path: $artifactName|g" $outputManifest if [ ! -z "$hostname" ]; then sed -i "s|host: .*$|host: ${hostname}|g" $outputManifest From da24592908c99af4af813e8a07d45956e82e0255 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sat, 13 Feb 2016 16:09:59 -0600 Subject: [PATCH 15/18] updated build to use maven ci profile for generating semver'd artifact --- ci/pipeline.yml | 6 ++--- ci/tasks/build.sh | 63 +++++++++++++++++++++++++++++++++++++++++++--- ci/tasks/build.yml | 8 ++++++ ci/tasks/unit.sh | 30 +++++++++++++++++++--- ci/tasks/unit.yml | 3 +++ pom.xml | 25 ++++++++++++------ 6 files changed, 118 insertions(+), 17 deletions(-) diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 56e5cbd..66c35ef 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -70,10 +70,10 @@ jobs: config: params: <<: *MAVENPARAMS - - task: prepare-build - file: pcfdemo/ci/tasks/prepare-build.yml +# - task: prepare-build +# file: pcfdemo/ci/tasks/prepare-build.yml - put: candidate-release - params: { from: prepare-build/pcf-demo-(.*).war } + params: { from: build/pcf-demo-(.*).war } - put: version params: { file: version/number } diff --git a/ci/tasks/build.sh b/ci/tasks/build.sh index 0f02b06..7ace4aa 100755 --- a/ci/tasks/build.sh +++ b/ci/tasks/build.sh @@ -1,9 +1,64 @@ #!/bin/sh -# Set the basedir for Maven wrapper script to find the .mvn folder -export MAVEN_BASEDIR=pcfdemo +inputDir= outputDir= versionFile= artifactId= packaging= -pcfdemo/mvnw --file=pcfdemo/pom.xml clean package +while [ $# -gt 0 ]; do + case $1 in + -i | --input-dir ) + inputDir=$2 + shift + ;; + -o | --output-dir ) + outputDir=$2 + shift + ;; + -v | --version-file ) + versionFile=$2 + shift + ;; + -a | --artifactId ) + artifactId=$2 + shift + ;; + -p | --packaging ) + packaging=$2 + shift + ;; + * ) + echo "Unrecognized option: $1" 1>&2 + exit 1 + ;; + esac + shift +done + +error_and_exit() { + echo $1 >&2 + exit 1 +} + +if [ ! -d "$inputDir" ]; then + error_and_exit "missing input directory: $inputDir" +fi +if [ ! -d "$outputDir" ]; then + error_and_exit "missing output directory: $outputDir" +fi +if [ ! -f "$versionFile" ]; then + error_and_exit "missing version file: $versionFile" +fi +if [ -z "$artifactId" ]; then + error_and_exit "missing artifactId!" +fi +if [ -z "$packaging" ]; then + error_and_exit "missing packaging!" +fi + +version=`cat $versionFile` +artifactName="${artifactId}-${version}.${packaging}" + +cd $inputDir +./mvnw clean package -Pci -DversionNumber=$version # Copy war file to concourse output folder -cp pcfdemo/target/*.war build/. +cd .. +cp $inputDir/target/$artifactName $outputDir/$artifactName diff --git a/ci/tasks/build.yml b/ci/tasks/build.yml index 2f3139b..0077dbc 100644 --- a/ci/tasks/build.yml +++ b/ci/tasks/build.yml @@ -9,9 +9,17 @@ params: inputs: - name: pcfdemo + - name: version outputs: - name: build run: path: pcfdemo/ci/tasks/build.sh + args: [ + --input-dir, pcfdemo, + --output-dir, build, + --version-file, version/number, + --artifactId, pcf-demo, + --packaging, war + ] diff --git a/ci/tasks/unit.sh b/ci/tasks/unit.sh index ce85671..7d0beda 100755 --- a/ci/tasks/unit.sh +++ b/ci/tasks/unit.sh @@ -1,6 +1,30 @@ #!/bin/sh -# Set the basedir for Maven wrapper script to find the .mvn folder -export MAVEN_BASEDIR=pcfdemo +inputDir= -pcfdemo/mvnw --file=pcfdemo/pom.xml clean test +while [ $# -gt 0 ]; do + case $1 in + -i | --input-dir ) + inputDir=$2 + shift + ;; + * ) + echo "Unrecognized option: $1" 1>&2 + exit 1 + ;; + esac + shift +done + +error_and_exit() { + echo $1 >&2 + exit 1 +} + +if [ ! -d "$inputDir" ]; then + error_and_exit "missing input directory: $inputDir" +fi + +cd $inputDir + +./mvnw clean test diff --git a/ci/tasks/unit.yml b/ci/tasks/unit.yml index 442bf99..0d51f56 100644 --- a/ci/tasks/unit.yml +++ b/ci/tasks/unit.yml @@ -12,3 +12,6 @@ inputs: run: path: pcfdemo/ci/tasks/unit.sh + args: [ + --input-dir, pcfdemo + ] diff --git a/pom.xml b/pom.xml index d396765..66743a4 100644 --- a/pom.xml +++ b/pom.xml @@ -17,20 +17,31 @@ 1.0.0-BUILD-SNAPSHOT + pcfdemo 1.6 3.1.1.RELEASE 1.6.10 1.6.6 + + + ci + + ${project.version} + ${project.artifactId}-${versionNumber} + + + + org.springframework.amqp spring-rabbit 1.2.0.RELEASE - - + + org.springframework @@ -61,14 +72,14 @@ 1.2.0.RELEASE - + org.springframework.cloud spring-cloud-cloudfoundry-connector 1.2.0.RELEASE - -