Harmonize CI pipeline

This commit is contained in:
Stephane Nicoll
2020-12-17 07:11:59 +01:00
parent d0cb9fc546
commit 35d40e3619
14 changed files with 272 additions and 163 deletions

View File

@@ -0,0 +1,17 @@
changelog:
repository: spring-io/initializr
sections:
- title: ":star: New Features"
labels:
- "type: enhancement"
- title: ":beetle: Bug Fixes"
labels:
- "type: bug"
- "type: regression"
- title: ":notebook_with_decorative_cover: Documentation"
labels:
- "type: documentation"
- title: ":hammer: Dependency Upgrades"
sort: "title"
labels:
- "type: dependency-upgrade"

View File

@@ -0,0 +1,9 @@
logging:
level:
io.spring.concourse: DEBUG
distribute:
optional-deployments:
- '.*\\.zip'
spring:
main:
banner-mode: off

View File

@@ -14,6 +14,7 @@ rm -rf /var/lib/apt/lists/*
curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.3/concourse-java.sh > /opt/concourse-java.sh curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.3/concourse-java.sh > /opt/concourse-java.sh
curl --output /opt/concourse-release-scripts.jar https://repo.spring.io/release/io/spring/concourse/releasescripts/concourse-release-scripts/0.2.1/concourse-release-scripts-0.2.1.jar
########################################################### ###########################################################
# JAVA # JAVA

View File

@@ -3,6 +3,9 @@ github-repo-name: "spring-io/initializr"
docker-hub-organization: "springci" docker-hub-organization: "springci"
artifactory-server: "https://repo.spring.io" artifactory-server: "https://repo.spring.io"
branch: "master" branch: "master"
milestone: "0.10.x"
build-name: "initializr" build-name: "initializr"
pipeline-name: "initializr"
concourse-url: "https://ci.spring.io" concourse-url: "https://ci.spring.io"
bintray-subject: "spring"
bintray-repo: "jars"
task-timeout: 30m

View File

@@ -1,3 +1,48 @@
anchors:
artifactory-repo-put-params: &artifactory-repo-put-params
repo: libs-snapshot-local
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
exclude:
- "**/*.effective-pom"
- "**/initializr-service-sample/**"
artifactory-task-params: &artifactory-task-params
ARTIFACTORY_SERVER: ((artifactory-server))
ARTIFACTORY_USERNAME: ((artifactory-username))
ARTIFACTORY_PASSWORD: ((artifactory-password))
bintray-task-params: &bintray-task-params
BINTRAY_SUBJECT: ((bintray-subject))
BINTRAY_REPO: ((bintray-repo))
BINTRAY_USERNAME: ((bintray-username))
BINTRAY_API_KEY: ((bintray-api-key))
build-project-task-params: &build-project-task-params
privileged: true
timeout: ((task-timeout))
file: git-repo/ci/tasks/build-project.yml
git-repo-resource-source: &git-repo-resource-source
uri: ((github-repo))
username: ((github-username))
password: ((github-password))
branch: ((branch))
registry-image-resource-source: &registry-image-resource-source
username: ((docker-hub-username))
password: ((docker-hub-password))
tag: ((milestone))
slack-fail-params: &slack-fail-params
text: ":concourse-failed: <!here> <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|failure: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME}>"
silent: true
icon_emoji: ":concourse:"
username: concourse-ci
slack-success-params: &slack-success-params
text: ":concourse-succeeded: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|success: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME}>"
silent: true
icon_emoji: ":concourse:"
username: concourse-ci
sontatype-task-params: &sonatype-task-params
SONATYPE_USER_TOKEN: ((sonatype-user-token))
SONATYPE_PASSWORD_TOKEN: ((sonatype-user-token-password))
resource_types: resource_types:
- name: artifactory-resource - name: artifactory-resource
type: registry-image type: registry-image
@@ -22,73 +67,73 @@ resource_types:
resources: resources:
- name: git-repo - name: git-repo
type: git type: git
icon: github
source: source:
uri: ((github-repo)) <<: *git-repo-resource-source
username: ((github-username))
password: ((github-password))
branch: ((branch))
ignore_paths: ["ci/images/*"]
- name: git-repo-windows - name: git-repo-windows
type: git type: git
icon: github
source: source:
uri: ((github-repo)) <<: *git-repo-resource-source
username: ((github-username))
password: ((github-password))
branch: ((branch))
ignore_paths: ["ci/images/*"]
git_config: git_config:
- name: core.autocrlf - name: core.autocrlf
value: true value: true
- name: git-pull-request - name: git-pull-request
type: pull-request type: pull-request
icon: source-pull
source: source:
access_token: ((github-ci-pull-request-token)) access_token: ((github-ci-pull-request-token))
repo: spring-io/initializr repository: ((github-repo-name))
base: ((branch)) base_branch: ((branch))
ignore_paths: ["ci/*"] ignore_paths: ["ci/*"]
- name: ci-images-git-repo
type: git
source:
uri: ((github-repo))
branch: ((branch))
paths: ["ci/images/*"]
- name: initializr-ci-image
type: registry-image
source:
repository: springci/initializr-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))
- name: slack-alert
type: slack-notification
source:
url: ((slack-webhook-url))
- name: repo-status-build
type: github-status-resource
source:
repository: spring-io/initializr
access_token: ((github-ci-status-token))
branch: ((branch))
context: build
- name: github-release - name: github-release
type: github-release type: github-release
icon: briefcase-download
source: source:
owner: spring-io owner: spring-io
repository: initializr repository: initializr
access_token: ((github-ci-release-token)) access_token: ((github-ci-release-token))
pre_release: false pre_release: false
- name: ci-images-git-repo
type: git
icon: github
source:
uri: ((github-repo))
branch: ((branch))
paths: ["ci/images/*"]
- name: ci-image
type: registry-image
icon: docker
source:
<<: *registry-image-resource-source
repository: ((docker-hub-organization))/initializr-ci
- name: artifactory-repo
type: artifactory-resource
icon: package-variant
source:
uri: ((artifactory-server))
username: ((artifactory-username))
password: ((artifactory-password))
build_name: ((build-name))
- name: repo-status-build
type: github-status-resource
icon: eye-check-outline
source:
repository: ((github-repo-name))
access_token: ((github-ci-status-token))
branch: ((branch))
context: build
- name: slack-alert
type: slack-notification
icon: slack
source:
url: ((slack-webhook-url))
- name: daily - name: daily
type: time type: time
source: {interval: 24h} icon: clock-outline
source: { interval: "24h" }
jobs: jobs:
- name: build-initializr-ci-image - name: build-ci-image
plan: plan:
- get: ci-images-git-repo - get: ci-images-git-repo
trigger: true trigger: true
@@ -98,67 +143,48 @@ jobs:
privileged: true privileged: true
file: git-repo/ci/tasks/build-ci-image.yml file: git-repo/ci/tasks/build-ci-image.yml
output_mapping: output_mapping:
image: initializr-ci-image image: ci-image
- put: initializr-ci-image - put: ci-image
params: params:
image: initializr-ci-image/image.tar image: ci-image/image.tar
- name: build - name: build
serial: true serial: true
public: true public: true
plan: plan:
- get: ci-image
- get: git-repo - get: git-repo
trigger: true trigger: true
- get: initializr-ci-image
- put: repo-status-build - put: repo-status-build
params: { state: "pending", commit: "git-repo" } params: { state: "pending", commit: "git-repo" }
- do: - do:
- task: build-project - task: build-project
image: initializr-ci-image image: ci-image
file: git-repo/ci/tasks/build-project.yml <<: *build-project-task-params
- put: artifactory-repo
params: &artifactory-params
repo: libs-snapshot-local
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
exclude:
- "**/*.effective-pom"
- "**/initializr-service-sample/**"
on_failure: on_failure:
do: do:
- put: repo-status-build - put: repo-status-build
params: { state: "failure", commit: "git-repo" } params: { state: "failure", commit: "git-repo" }
- put: slack-alert - put: slack-alert
params: params:
text: ":concourse-failed: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|failure: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME}>" <<: *slack-fail-params
silent: true
icon_emoji: ":concourse:"
username: concourse-ci
- put: repo-status-build - put: repo-status-build
params: { state: "success", commit: "git-repo" } params: { state: "success", commit: "git-repo" }
- put: artifactory-repo
params:
<<: *artifactory-repo-put-params
on_failure:
do:
- put: slack-alert
params:
<<: *slack-fail-params
- put: slack-alert - put: slack-alert
params: params:
text: ":concourse-succeeded: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|success: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME}>" <<: *slack-success-params
silent: true
icon_emoji: ":concourse:"
username: concourse-ci
- name: windows-build
serial: true
public: true
plan:
- get: daily
trigger: true
- get: git-repo
resource: git-repo-windows
- task: build-project
tags: [WIN64]
file: git-repo/ci/tasks/build-project-windows.yml
- name: build-pull-requests - name: build-pull-requests
serial: true serial: true
public: true public: true
plan: plan:
- get: initializr-ci-image - get: ci-image
- get: git-repo - get: git-repo
resource: git-pull-request resource: git-pull-request
trigger: true trigger: true
@@ -169,30 +195,56 @@ jobs:
path: git-repo path: git-repo
status: pending status: pending
- task: build-project - task: build-project
image: initializr-ci-image image: ci-image
file: git-repo/ci/tasks/build-pr-project.yml file: git-repo/ci/tasks/build-pr-project.yml
on_success: on_success:
put: git-pull-request put: git-pull-request
params:
path: git-repo
status: success
on_failure:
put: git-pull-request
params:
path: git-repo
status: failure
- name: windows-build
serial: true
plan:
- get: git-repo
resource: git-repo-windows
- get: daily
trigger: true
- do:
- task: build-project
privileged: true
file: git-repo/ci/tasks/build-project-windows.yml
tags: [ WIN64 ]
timeout: ((task-timeout))
params:
BRANCH: ((branch))
on_failure:
do:
- put: slack-alert
params: params:
path: git-repo <<: *slack-fail-params
status: success - put: slack-alert
on_failure: params:
put: git-pull-request <<: *slack-success-params
params:
path: git-repo
status: failure
- name: stage-release - name: stage-release
serial: true serial: true
plan: plan:
- get: initializr-ci-image - get: ci-image
- get: git-repo - get: git-repo
trigger: false trigger: false
- task: stage - task: stage
image: initializr-ci-image image: ci-image
file: git-repo/ci/tasks/stage.yml file: git-repo/ci/tasks/stage.yml
- put: artifactory-repo - put: artifactory-repo
params: params:
<<: *artifactory-params RELEASE_TYPE: RELEASE
- put: artifactory-repo
params:
<<: *artifactory-repo-put-params
repo: libs-staging-local repo: libs-staging-local
- put: git-repo - put: git-repo
params: params:
@@ -200,39 +252,56 @@ jobs:
- name: promote-release - name: promote-release
serial: true serial: true
plan: plan:
- get: initializr-ci-image - get: ci-image
- get: git-repo - get: git-repo
trigger: false trigger: false
- get: artifactory-repo - get: artifactory-repo
trigger: false trigger: false
passed: [stage-release] passed: [stage-release]
params: params:
download_artifacts: false
save_build_info: true save_build_info: true
- task: promote - task: promote
image: initializr-ci-image image: ci-image
file: git-repo/ci/tasks/promote.yml file: git-repo/ci/tasks/promote.yml
params: params:
ARTIFACTORY_SERVER: ((artifactory-server)) RELEASE_TYPE: RELEASE
ARTIFACTORY_USERNAME: ((artifactory-username)) <<: *artifactory-task-params
ARTIFACTORY_PASSWORD: ((artifactory-password)) <<: *bintray-task-params
- task: generate-release-notes - name: sync-to-maven-central
file: git-repo/ci/tasks/generate-release-notes.yml serial: true
plan:
- get: ci-image
- get: git-repo
- get: artifactory-repo
trigger: true
passed: [promote-release]
params: params:
GITHUB_ORGANIZATION: spring-io download_artifacts: false
GITHUB_REPO: initializr save_build_info: true
- task: sync-to-maven-central
image: ci-image
file: git-repo/ci/tasks/sync-to-maven-central.yml
params:
<<: *bintray-task-params
<<: *sonatype-task-params
- task: generate-changelog
file: git-repo/ci/tasks/generate-changelog.yml
params:
RELEASE_TYPE: RELEASE
GITHUB_USERNAME: ((github-username)) GITHUB_USERNAME: ((github-username))
GITHUB_TOKEN: ((github-ci-release-token)) GITHUB_TOKEN: ((github-ci-release-token))
- put: github-release - put: github-release
params: params:
name: generated-release-notes/version name: generated-changelog/tag
tag: generated-release-notes/version tag: generated-changelog/tag
body: generated-release-notes/body body: generated-changelog/changelog.md
groups: groups:
- name: "build" - name: "build"
jobs: ["build", "windows-build"] jobs: ["build", "windows-build"]
- name: "releases" - name: "releases"
jobs: ["stage-release", "promote-release"] jobs: ["stage-release", "promote-release", "sync-to-maven-central"]
- name: "ci-images" - name: "ci-images"
jobs: ["build-initializr-ci-image"] jobs: ["build-ci-image"]
- name: "pull-requests" - name: "pull-requests"
jobs: ["build-pull-requests"] jobs: ["build-pull-requests"]

View File

@@ -0,0 +1,12 @@
#!/bin/bash
set -e
CONFIG_DIR=git-repo/ci/config
version=$( cat version/version )
java -jar /github-changelog-generator.jar \
--spring.config.location=${CONFIG_DIR}/changelog-generator.yml \
${version} generated-changelog/changelog.md
echo ${version} > generated-changelog/version
echo v${version} > generated-changelog/tag

View File

@@ -1,16 +0,0 @@
#!/bin/bash
set -e
version=$( cat version/version )
milestone=${version}
java -jar /github-release-notes-generator.jar \
--releasenotes.github.username=${GITHUB_USERNAME} \
--releasenotes.github.password=${GITHUB_TOKEN} \
--releasenotes.github.organization=${GITHUB_ORGANIZATION} \
--releasenotes.github.repository=${GITHUB_REPO} \
${milestone} generated-release-notes/release-notes.md
echo ${version} > generated-release-notes/version
echo v${version} > generated-release-notes/tag

View File

@@ -1,27 +1,16 @@
#!/bin/bash #!/bin/bash
set -e
source $(dirname $0)/common.sh source $(dirname $0)/common.sh
CONFIG_DIR=git-repo/ci/config
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/' ) version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json
targetRepo="libs-release-local" java -jar /opt/concourse-release-scripts.jar promote $RELEASE_TYPE $BUILD_INFO_LOCATION || { exit 1; }
echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}" java -jar /opt/concourse-release-scripts.jar \
--spring.config.location=${CONFIG_DIR}/release-scripts.yml \
curl \ distribute $RELEASE_TYPE $BUILD_INFO_LOCATION || { exit 1; }
-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" echo "Promotion complete"
echo $version > version/version echo $version > version/version

View File

@@ -0,0 +1,8 @@
#!/bin/bash
export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json
version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
java -jar /opt/concourse-release-scripts.jar syncToCentral "RELEASE" $BUILD_INFO_LOCATION || { exit 1; }
echo "Sync complete"
echo $version > version/version

View File

@@ -12,7 +12,7 @@ caches:
- path: ci-image-cache - path: ci-image-cache
params: params:
CONTEXT: ci-images-git-repo/ci/images CONTEXT: ci-images-git-repo/ci/images
DOCKERFILE: ci-images-git-repo/ci/images/initializr-ci-image/Dockerfile DOCKERFILE: ci-images-git-repo/ci/images/ci-image/Dockerfile
REGISTRY_MIRRORS: ((docker-hub-mirror)) REGISTRY_MIRRORS: ((docker-hub-mirror))
DOCKER_HUB_AUTH: ((docker-hub-auth)) DOCKER_HUB_AUTH: ((docker-hub-auth))
run: run:

View File

@@ -0,0 +1,20 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: springio/github-changelog-generator
tag: '0.0.5'
inputs:
- name: git-repo
- name: version
outputs:
- name: generated-changelog
params:
GITHUB_ORGANIZATION:
GITHUB_REPO:
GITHUB_USERNAME:
GITHUB_TOKEN:
RELEASE_TYPE:
run:
path: git-repo/ci/scripts/generate-changelog.sh

View File

@@ -1,19 +0,0 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: springio/github-release-notes-generator
tag: '0.0.2'
inputs:
- name: git-repo
- name: version
outputs:
- name: generated-release-notes
params:
GITHUB_ORGANIZATION:
GITHUB_REPO:
GITHUB_USERNAME:
GITHUB_TOKEN:
run:
path: git-repo/ci/scripts/generate-release-notes.sh

View File

@@ -0,0 +1,16 @@
---
platform: linux
inputs:
- name: git-repo
- name: artifactory-repo
outputs:
- name: version
params:
BINTRAY_REPO:
BINTRAY_SUBJECT:
BINTRAY_USERNAME:
BINTRAY_API_KEY:
SONATYPE_USER_TOKEN:
SONATYPE_PASSWORD_TOKEN:
run:
path: git-repo/ci/scripts/sync-to-maven-central.sh