Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from Pivotal-Field-Engineering/master
Browse files Browse the repository at this point in the history
Merge latest from Pivotal-Field-Engineering
  • Loading branch information
patrickcrocker committed Mar 28, 2016
2 parents 893189f + 3148418 commit 0ac8ddc
Show file tree
Hide file tree
Showing 20 changed files with 529 additions and 231 deletions.
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Additional fun: click "Kill App" and watch the application crashing.. it will sh

## Concourse CI Pipeline

Please take a look at the ci folder to see the Concourse CI Pipeline.
Please take a look at the [ci](ci/README.md) folder to see the [Concourse](http://concourse.ci/) CI Pipeline.
12 changes: 8 additions & 4 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:

Expand Down
8 changes: 6 additions & 2 deletions ci/pcfdemo-properties-sample.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
github-uri: https://github.com/.../PCF-demo.git
s3-access-key-id: SAMPLEDF99FSWEBF9DW9
s3-secret-access-key: sampleaxfdpiA98FG8u7ahd08Sdgf8AFG8gh8S0F
github-branch: master
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
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
cf-org: micropcf-org
cf-space: micropcf-space
cf-manifest-host: pcfdemo-ci
github-private-key: |
-----BEGIN RSA PRIVATE KEY-----
SamplejjkKiRxGdgR8p5kZJj0AFgdWYa3OT2snIXnN5+/p7j13PSkseUcrAFyokc
Expand Down
24 changes: 17 additions & 7 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ resources:
type: git
source:
uri: {{github-uri}}
branch: master
branch: {{github-branch}}

- name: version
type: semver
source:
bucket: {{s3-bucket-version}}
initial_version: 1.0.0-rc.1
initial_version: 1.0.0-rc.0
key: current-version
access_key_id: {{s3-access-key-id}}
secret_access_key: {{s3-secret-access-key}}
Expand Down Expand Up @@ -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 ]
Expand All @@ -63,10 +67,11 @@ jobs:
params: { pre: rc }
- task: build
file: pcfdemo/ci/tasks/build.yml
- task: prepare-build
file: pcfdemo/ci/tasks/prepare-build.yml
config:
params:
<<: *MAVENPARAMS
- put: candidate-release
params: { from: prepare-build/pcf-demo-(.*).war }
params: { from: build/pcf-demo-(.*).war }
- put: version
params: { file: version/number }

Expand All @@ -82,12 +87,17 @@ jobs:
passed: [ build-artifact ]
- task: prepare-integration
file: pcfdemo/ci/tasks/prepare-integration.yml
config:
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:
params:
<<: *MAVENPARAMS

- name: ship-it
serial_groups: [ version ]
Expand Down
64 changes: 61 additions & 3 deletions ci/tasks/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +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
cd ..
cp $inputDir/target/$artifactName $outputDir/$artifactName
18 changes: 18 additions & 0 deletions ci/tasks/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
---
platform: linux

image: docker:///java#8

params:
MAVEN_OPTS:
MAVEN_CONFIG:

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
]
30 changes: 27 additions & 3 deletions ci/tasks/integration.sh
Original file line number Diff line number Diff line change
@@ -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 verify
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 verify
6 changes: 6 additions & 0 deletions ci/tasks/integration.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
---
platform: linux

image: docker:///java#8

inputs:
- name: pcfdemo

run:
path: pcfdemo/ci/tasks/integration.sh
args: [
--input-dir, pcfdemo
]
10 changes: 0 additions & 10 deletions ci/tasks/prepare-build.yml

This file was deleted.

51 changes: 51 additions & 0 deletions ci/tasks/prepare-final.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

baseName="pcf-demo"

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

if [ ! -d "$inputDir" ]; then
echo "missing input directory!"
exit 1
fi

if [ ! -d "$outputDir" ]; then
echo "missing output directory!"
exit 1
fi

if [ -f "$versionFile" ]; then
version=`cat $versionFile`
baseName="${baseName}-${version}"
fi

inputWar=`find $inputDir -name '*.war'`
outputWar="${outputDir}/${baseName}.war"

echo "Renaming ${inputWar} to ${outputWar}"

cp ${inputWar} ${outputWar}
14 changes: 12 additions & 2 deletions ci/tasks/prepare-final.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
---
platform: linux

image: docker:///java#8

inputs:
- name: pcfdemo
- name: candidate-release
- name: version

outputs:
- name: prepare-final

run:
path: pcfdemo/ci/tasks/rename-artifact.sh
args: ["-d", "candidate-release", "-v", "version/number"]
path: pcfdemo/ci/tasks/prepare-final.sh
args: [
"--input-dir", "candidate-release",
"--output-dir", "prepare-final",
"--version-file", "version/number"
]
Loading

0 comments on commit 0ac8ddc

Please sign in to comment.