Add CI infrastructure with Concourse
This commit adds the CI infrastructure for running builds with Concourse. This includes: * a docker image for the CI image (JDK 8 based) * a set of Concourse pipelines for building, staging and promoting artifacts
This commit is contained in:
parent
b7bfc332db
commit
5addf686b8
|
@ -9,6 +9,12 @@ group = 'io.spring.docresources'
|
|||
description = 'Spring Documentation Resources'
|
||||
version = "0.1.0-BUILD-SNAPSHOT"
|
||||
|
||||
node {
|
||||
version = '11.2.0'
|
||||
npmVersion = '6.4.1'
|
||||
download = true
|
||||
}
|
||||
|
||||
distributions {
|
||||
main {
|
||||
baseName = 'spring-doc-resources'
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
credentials.yml
|
|
@ -0,0 +1,37 @@
|
|||
== Concourse pipeline
|
||||
|
||||
The pipeline can be deployed using the following command:
|
||||
|
||||
[source]
|
||||
----
|
||||
$ fly -t spring set-pipeline -p spring-doc-resources -c ci/pipeline.yml -l ci/parameters.yml
|
||||
----
|
||||
|
||||
NOTE: This assumes that you have credhub integration configured with the appropriate
|
||||
secrets.
|
||||
|
||||
=== Release
|
||||
|
||||
To release a milestone:
|
||||
|
||||
[source]
|
||||
----
|
||||
$ fly -t spring trigger-job -j spring-doc-resources/stage-milestone
|
||||
$ fly -t spring trigger-job -j spring-doc-resources/promote-milestone
|
||||
----
|
||||
|
||||
To release an RC:
|
||||
|
||||
[source]
|
||||
----
|
||||
$ fly -t spring trigger-job -j spring-doc-resources/stage-rc
|
||||
$ fly -t spring trigger-job -j spring-doc-resources/promote-rc
|
||||
----
|
||||
|
||||
To release a GA:
|
||||
|
||||
[source]
|
||||
----
|
||||
$ fly -t spring trigger-job -j spring-doc-resources/stage-release
|
||||
$ fly -t spring trigger-job -j spring-doc-resources/promote-release
|
||||
----
|
|
@ -0,0 +1,13 @@
|
|||
FROM ubuntu:bionic-20181018
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install --no-install-recommends -y ca-certificates net-tools git curl
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV JAVA_HOME /opt/openjdk
|
||||
ENV PATH $JAVA_HOME/bin:$PATH
|
||||
RUN mkdir -p /opt/openjdk && \
|
||||
cd /opt/openjdk && \
|
||||
curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u192-b12/OpenJDK8U-jdk_x64_linux_hotspot_8u192b12.tar.gz | tar xz --strip-components=2
|
||||
|
||||
ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.2/concourse-java.sh /opt/
|
|
@ -0,0 +1,6 @@
|
|||
github-repo: "https://github.com/spring-io/spring-doc-resources.git"
|
||||
github-repo-name: "spring-io/spring-doc-resources"
|
||||
docker-hub-organization: "springci"
|
||||
artifactory-server: "https://repo.spring.io"
|
||||
branch: "master"
|
||||
build-name: "spring-doc-resources"
|
|
@ -0,0 +1,108 @@
|
|||
resource_types:
|
||||
- name: artifactory-resource
|
||||
type: docker-image
|
||||
source:
|
||||
repository: springio/artifactory-resource
|
||||
tag: 0.0.7-SNAPSHOT
|
||||
resources:
|
||||
- name: git-repo
|
||||
type: git
|
||||
source:
|
||||
uri: ((github-repo))
|
||||
username: ((github-username))
|
||||
password: ((github-password))
|
||||
branch: ((branch))
|
||||
ignore_paths: ["ci/images/*"]
|
||||
- name: ci-images-git-repo
|
||||
type: git
|
||||
source:
|
||||
uri: ((github-repo))
|
||||
branch: ((branch))
|
||||
paths: ["ci/images/*"]
|
||||
- name: spring-doc-resources-ci-image
|
||||
type: docker-image
|
||||
source:
|
||||
repository: ((docker-hub-organization))/spring-doc-resources-ci-image
|
||||
username: ((docker-hub-username))
|
||||
password: ((docker-hub-password))
|
||||
tag: ((branch))
|
||||
- name: artifactory-repo
|
||||
type: artifactory-resource
|
||||
source:
|
||||
uri: ((artifactory-server))
|
||||
username: ((artifactory-username))
|
||||
password: ((artifactory-password))
|
||||
build_name: ((build-name))
|
||||
jobs:
|
||||
- name: build-spring-doc-resources-ci-images
|
||||
plan:
|
||||
- get: ci-images-git-repo
|
||||
trigger: true
|
||||
- put: spring-doc-resources-ci-image
|
||||
params:
|
||||
build: ci-images-git-repo/ci/images/spring-doc-resources-ci-image
|
||||
- name: build
|
||||
serial: true
|
||||
public: true
|
||||
plan:
|
||||
- get: spring-doc-resources-ci-image
|
||||
- get: git-repo
|
||||
trigger: true
|
||||
- do:
|
||||
- task: build-project
|
||||
privileged: true
|
||||
timeout: 30m
|
||||
image: spring-doc-resources-ci-image
|
||||
file: git-repo/ci/tasks/build-project.yml
|
||||
- put: artifactory-repo
|
||||
params: &artifactory-params
|
||||
repo: libs-snapshot-local
|
||||
build_number: "${BUILD_ID}"
|
||||
folder: distribution-repository
|
||||
build_uri: "https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}"
|
||||
build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}"
|
||||
disable_checksum_uploads: true
|
||||
- name: stage-release
|
||||
serial: true
|
||||
plan:
|
||||
- get: spring-doc-resources-ci-image
|
||||
- get: git-repo
|
||||
trigger: false
|
||||
- task: stage
|
||||
image: spring-doc-resources-ci-image
|
||||
file: git-repo/ci/tasks/stage.yml
|
||||
params:
|
||||
RELEASE_TYPE: RELEASE
|
||||
- put: artifactory-repo
|
||||
params:
|
||||
<<: *artifactory-params
|
||||
repo: libs-staging-local
|
||||
- put: git-repo
|
||||
params:
|
||||
repository: stage-git-repo
|
||||
- name: promote-release
|
||||
serial: true
|
||||
plan:
|
||||
- get: spring-doc-resources-ci-image
|
||||
- get: git-repo
|
||||
trigger: false
|
||||
- get: artifactory-repo
|
||||
trigger: false
|
||||
passed: [stage-release]
|
||||
params:
|
||||
save_build_info: true
|
||||
- task: promote
|
||||
image: spring-doc-resources-ci-image
|
||||
file: git-repo/ci/tasks/promote.yml
|
||||
params:
|
||||
RELEASE_TYPE: RELEASE
|
||||
ARTIFACTORY_SERVER: ((artifactory-server))
|
||||
ARTIFACTORY_USERNAME: ((artifactory-username))
|
||||
ARTIFACTORY_PASSWORD: ((artifactory-password))
|
||||
groups:
|
||||
- name: "Build"
|
||||
jobs: ["build"]
|
||||
- name: "Release"
|
||||
jobs: ["stage-release", "promote-release"]
|
||||
- name: "CI Images"
|
||||
jobs: ["build-spring-doc-resources-ci-images"]
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/common.sh
|
||||
repository=$(pwd)/distribution-repository
|
||||
|
||||
pushd git-repo > /dev/null
|
||||
./gradlew --no-daemon clean distZip publishToMavenLocal -Dmaven.repo.local=${repository}
|
||||
popd > /dev/null
|
|
@ -0,0 +1,4 @@
|
|||
source /opt/concourse-java.sh
|
||||
export TERM=dumb
|
||||
setup_symlinks
|
||||
cleanup_maven_repo "io.spring.gradle"
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/common.sh
|
||||
|
||||
buildName=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' )
|
||||
buildNumber=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' )
|
||||
groupId=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
|
||||
version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
|
||||
|
||||
|
||||
if [[ $RELEASE_TYPE = "M" ]]; then
|
||||
targetRepo="libs-milestone-local"
|
||||
elif [[ $RELEASE_TYPE = "RC" ]]; then
|
||||
targetRepo="libs-milestone-local"
|
||||
elif [[ $RELEASE_TYPE = "RELEASE" ]]; then
|
||||
targetRepo="libs-release-local"
|
||||
else
|
||||
echo "Unknown release type $RELEASE_TYPE" >&2; exit 1;
|
||||
fi
|
||||
|
||||
echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}"
|
||||
|
||||
curl \
|
||||
-s \
|
||||
--connect-timeout 240 \
|
||||
--max-time 900 \
|
||||
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
|
||||
-H "Content-type:application/json" \
|
||||
-d "{\"status\": \"staged\", \"sourceRepo\": \"libs-staging-local\", \"targetRepo\": \"${targetRepo}\"}" \
|
||||
-f \
|
||||
-X \
|
||||
POST "${ARTIFACTORY_SERVER}/api/build/promote/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to promote" >&2; exit 1; }
|
||||
|
||||
echo "Promotion complete"
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/common.sh
|
||||
repository=$(pwd)/distribution-repository
|
||||
|
||||
pushd git-repo > /dev/null
|
||||
git fetch --tags --all > /dev/null
|
||||
popd > /dev/null
|
||||
|
||||
git clone git-repo stage-git-repo > /dev/null
|
||||
|
||||
pushd stage-git-repo > /dev/null
|
||||
|
||||
snapshotVersion=$( awk -F '=' '$1 == "version" { print $2 }' gradle.properties )
|
||||
if [[ $RELEASE_TYPE = "RELEASE" ]]; then
|
||||
stageVersion=$( strip_snapshot_suffix $snapshotVersion)
|
||||
nextVersion=$( bump_version_number $snapshotVersion)
|
||||
else
|
||||
echo "Unknown release type $RELEASE_TYPE" >&2; exit 1;
|
||||
fi
|
||||
|
||||
echo "Staging $stageVersion (next version will be $nextVersion)"
|
||||
sed -i "" "s/version=$snapshotVersion/version=$stageVersion/" gradle.properties
|
||||
|
||||
git config user.name "Spring Buildmaster" > /dev/null
|
||||
git config user.email "buildmaster@springframework.org" > /dev/null
|
||||
git add pom.xml > /dev/null
|
||||
git commit -m"Release v$stageVersion" > /dev/null
|
||||
git tag -a "v$stageVersion" -m"Release v$stageVersion" > /dev/null
|
||||
|
||||
./gradlew --no-daemon clean build install -Dmaven.repo.local=${repository}
|
||||
|
||||
git reset --hard HEAD^ > /dev/null
|
||||
echo "Setting next development version (v$nextVersion)"
|
||||
sed -i "" "s/version=$snapshotVersion/version=$nextVersion/" gradle.properties
|
||||
git add . > /dev/null
|
||||
git commit -m"Next development version (v$nextVersion)" > /dev/null
|
||||
|
||||
echo "DONE"
|
||||
|
||||
popd > /dev/null
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
platform: linux
|
||||
inputs:
|
||||
- name: git-repo
|
||||
outputs:
|
||||
- name: distribution-repository
|
||||
caches:
|
||||
- path: maven
|
||||
- path: gradle
|
||||
run:
|
||||
path: bash
|
||||
args:
|
||||
- -ec
|
||||
- |
|
||||
${PWD}/git-repo/ci/scripts/build-project.sh
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
platform: linux
|
||||
inputs:
|
||||
- name: git-repo
|
||||
- name: artifactory-repo
|
||||
run:
|
||||
path: git-repo/ci/scripts/promote.sh
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
platform: linux
|
||||
inputs:
|
||||
- name: git-repo
|
||||
outputs:
|
||||
- name: stage-git-repo
|
||||
- name: distribution-repository
|
||||
caches:
|
||||
- path: maven
|
||||
- path: gradle
|
||||
run:
|
||||
path: git-repo/ci/scripts/stage.sh
|
Loading…
Reference in New Issue