From f8a1d05bd7c085b136ad807e3b1b0399ebbde112 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 1 Mar 2018 14:32:06 -0800 Subject: [PATCH 1/2] Add git config to mock repo --- test/get_next_release.bats | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/get_next_release.bats b/test/get_next_release.bats index ebb4c20..5631f0c 100644 --- a/test/get_next_release.bats +++ b/test/get_next_release.bats @@ -102,6 +102,8 @@ mock_git_repo() { mkdir -p "$tmpdir" >&2 cd "$tmpdir" >&2 git init >&2 + git config user.name "Test User" >&2 + git config user.email "test@example.org" >&2 echo "foo" > foo.txt git add foo.txt >&2 git commit -m'Initial commit' >&2 From 5e38409e51c4c8392d433613e919a2b0d75c35b6 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 1 Mar 2018 14:32:18 -0800 Subject: [PATCH 2/2] Add concourse CI pipeline --- ci/README.adoc | 30 ++++++++ .../Dockerfile | 4 ++ ci/pipeline.yml | 71 +++++++++++++++++++ ci/scripts/release.sh | 15 ++++ ci/scripts/test.sh | 8 +++ 5 files changed, 128 insertions(+) create mode 100644 ci/README.adoc create mode 100644 ci/images/concourse-java-scripts-ci-image/Dockerfile create mode 100644 ci/pipeline.yml create mode 100755 ci/scripts/release.sh create mode 100755 ci/scripts/test.sh diff --git a/ci/README.adoc b/ci/README.adoc new file mode 100644 index 0000000..49c11ac --- /dev/null +++ b/ci/README.adoc @@ -0,0 +1,30 @@ +== Concourse pipeline + +To set the pipeline first create a file in this directory called `secrets.yml`: + +[source,yaml] +.secrets.yml +---- +docker-hub-username: "" +docker-hub-password: "" +github-username: "" +github-password: "" +---- + +NOTE: The file should be ignored by git, make sure that you don't commit it! + +Once the file has been created, the pipeline can be deployed: + +[source] +---- +$ fly -t spring set-pipeline -p concourse-java-scripts -c ci/pipeline.yml --load-vars-from secrets.yml +---- + +=== Release + +To perform a release run: + +[source] +---- +$ fly -t spring trigger-job -j concourse-java-scripts/release +---- diff --git a/ci/images/concourse-java-scripts-ci-image/Dockerfile b/ci/images/concourse-java-scripts-ci-image/Dockerfile new file mode 100644 index 0000000..63874e2 --- /dev/null +++ b/ci/images/concourse-java-scripts-ci-image/Dockerfile @@ -0,0 +1,4 @@ +FROM debian + +RUN apt-get update && \ + apt-get install -y git \ No newline at end of file diff --git a/ci/pipeline.yml b/ci/pipeline.yml new file mode 100644 index 0000000..9e44aec --- /dev/null +++ b/ci/pipeline.yml @@ -0,0 +1,71 @@ +resources: +- name: git-repo + type: git + source: + uri: https://github.com/mbhave/concourse-java-scripts + branch: master + ignore_paths: ["ci/images/*"] +- name: ci-images-git-repo + type: git + source: + uri: https://github.com/mbhave/concourse-java-scripts + username: ((github-username)) + password: ((github-password)) + branch: master + paths: ["ci/images/*"] +- name: concourse-java-scripts-ci-image + type: docker-image + source: + repository: mbhave/concourse-java-scripts-ci-image + username: ((docker-hub-username)) + password: ((docker-hub-password)) + tag: master +jobs: +- name: build-concourse-java-scripts-ci-image + plan: + - get: ci-images-git-repo + trigger: true + - put: concourse-java-scripts-ci-image + params: + build: ci-images-git-repo/ci/images/concourse-java-scripts-ci-image +- name: test + plan: + - get: git-repo + trigger: true + - task: test + config: + platform: linux + image_resource: + type: docker-image + source: + repository: mbhave/concourse-java-scripts-ci-image + tag: master + inputs: + - name: git-repo + run: + path: git-repo/ci/scripts/test.sh +- name: release + plan: + - get: git-repo + passed: [test] + trigger: false + - task: release + config: + platform: linux + image_resource: + type: docker-image + source: + repository: mbhave/concourse-java-scripts-ci-image + tag: master + inputs: + - name: git-repo + params: + MINOR_VERSION: 0 + MAJOR_VERSION: 0 + run: + path: git-repo/ci/scripts/release.sh + - put: git-repo + params: + repository: release-git-repo + + diff --git a/ci/scripts/release.sh b/ci/scripts/release.sh new file mode 100755 index 0000000..7538877 --- /dev/null +++ b/ci/scripts/release.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +git clone git-repo release-git-repo + +pushd release-git-repo > /dev/null + git fetch --tags --all + last=$( git tag --list "v${MAJOR_VERSION}.${MINOR_VERSION}*"| sed -E "s/^.*${2}([0-9]+)$/\1/g" | sort -rn | head -n1 ) + next=$((last+1)) + releaseVersion=v${MAJOR_VERSION}.${MINOR_VERSION}.$next + echo "Releasing $releaseVersion" + git config user.name "Spring Buildmaster" > /dev/null + git config user.email "buildmaster@springframework.org" > /dev/null + git tag -a "v$releaseVersion" -m"Release v$releaseVersion" > /dev/null +popd > /dev/null diff --git a/ci/scripts/test.sh b/ci/scripts/test.sh new file mode 100755 index 0000000..239c004 --- /dev/null +++ b/ci/scripts/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +export TERM=dumb + +pushd git-repo + ./test.sh +popd \ No newline at end of file