diff --git a/ci/README.adoc b/ci/README.adoc index c31d8a9..a26b414 100644 --- a/ci/README.adoc +++ b/ci/README.adoc @@ -28,8 +28,8 @@ WARNING: Do NOT check this file into source control! If you'll check, `credentia With this in place, run the following `fly` commands to create pipelines: ---- -% fly -t sp -p spring-session-data-mongodb -c ci/pipeline-template.yml -l credentials.yml -v branch=master -v release-branch=release -% fly -t sp -p spring-session-data-mongodb-2.0.x -c ci/pipeline-template.yml -l credentials.yml -v branch=2.0.x -v release-branch=release-2.0.x +% fly -t spring-team sp -p spring-session-data-mongodb -c ci/pipeline-template.yml -l credentials.yml -v branch=master -v release-branch=release +% fly -t spring-team sp -p spring-session-data-mongodb-2.0.x -c ci/pipeline-template.yml -l credentials.yml -v branch=2.0.x -v release-branch=release-2.0.x ---- This creates pipelines for: @@ -40,8 +40,8 @@ This creates pipelines for: With these pipelines in place, you can now activate and expose them: ---- -% fly -t unpause-pipeline -p spring-session-data-mongodb -% fly -t expose-pipeline -p spring-session-data-mongodb -% fly -t unpause-pipeline -p spring-session-data-mongodb-2.0.x -% fly -t expose-pipeline -p spring-session-data-mongodb-2.x +% fly -t spring-team unpause-pipeline -p spring-session-data-mongodb +% fly -t spring-team expose-pipeline -p spring-session-data-mongodb +% fly -t spring-team unpause-pipeline -p spring-session-data-mongodb-2.0.x +% fly -t spring-team expose-pipeline -p spring-session-data-mongodb-2.x ---- \ No newline at end of file diff --git a/ci/pipeline-template.yml b/ci/pipeline-template.yml index 1e6619f..621b81d 100644 --- a/ci/pipeline-template.yml +++ b/ci/pipeline-template.yml @@ -104,6 +104,7 @@ groups: jobs: - release-to-artifactory - promote-to-bintray + - sync-to-maven-central jobs: - name: Test - JDK 8 @@ -683,7 +684,6 @@ jobs: - name: promote-to-bintray serial: true - public: true plan: - get: spring-session-data-mongodb-artifactory trigger: true @@ -725,3 +725,51 @@ jobs: text: "Promoting to bintray has succeeded!" title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + +- name: sync-to-maven-central + serial: true + plan: + - get: spring-session-data-mongodb-github + resource: spring-session-data-mongodb-release + - get: spring-session-data-mongodb-artifactory + trigger: true + passed: [promote-to-bintray] + params: + save_build_info: true + - task: sync-to-maven-central + file: spring-session-data-mongodb-github/ci/sync-to-maven-central.yml + params: + BINTRAY_USERNAME: ((bintray-username)) + BINTRAY_API_KEY: ((bintray-api-key)) + SONATYPE_USER_TOKEN: ((sonatype-user-token)) + SONATYPE_PASSWORD_TOKEN: ((sonatype-user-token-password)) + ARTIFACTORY_USERNAME: ((artifactory-username)) + ARTIFACTORY_PASSWORD: ((artifactory-password)) + on_failure: + aggregate: + - put: spring-session-data-mongodb-status + params: + commit: spring-session-data-mongodb-github + state: failure + - put: slack + params: + attachments: + - color: danger + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Syncing to maven central has failed" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + on_success: + aggregate: + - put: spring-session-data-mongodb-status + params: + commit: spring-session-data-mongodb-github + state: success + - put: slack + params: + attachments: + - color: good + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Syncing to maven central has succeeded!" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME diff --git a/ci/sync-to-maven-central.sh b/ci/sync-to-maven-central.sh new file mode 100755 index 0000000..461ea05 --- /dev/null +++ b/ci/sync-to-maven-central.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e -u + +apt-get update +apt-get install -y jq + +buildName=$( cat spring-session-data-mongodb-artifactory/build-info.json | jq -r '.buildInfo.name' ) +buildNumber=$( cat spring-session-data-mongodb-artifactory/build-info.json | jq -r '.buildInfo.number' ) +groupId=$( cat spring-session-data-mongodb-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' ) +version=$( cat spring-session-data-mongodb-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) + +echo "Syncing ${buildName}/${buildNumber} to Maven Central" + curl \ + -s \ + --connect-timeout 240 \ + --max-time 2700 \ + -u ${BINTRAY_USERNAME}:${BINTRAY_API_KEY} \ + -H "Content-Type: application/json" -d "{ \"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \ + -f \ + -X \ + POST "https://api.bintray.com/maven_central_sync/spring/jars/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; } + +echo "Sync complete" diff --git a/ci/sync-to-maven-central.yml b/ci/sync-to-maven-central.yml new file mode 100644 index 0000000..76cd449 --- /dev/null +++ b/ci/sync-to-maven-central.yml @@ -0,0 +1,21 @@ +--- +platform: linux + +image_resource: + type: docker-image + source: + repository: openjdk + tag: 8-jdk + +inputs: +- name: spring-session-data-mongodb-artifactory +- name: spring-session-data-mongodb-github + +run: + path: spring-session-data-mongodb-github/ci/sync-to-maven-central.sh + +params: + BINTRAY_USERNAME: + BINTRAY_API_KEY: + SONATYPE_USER_TOKEN: + SONATYPE_PASSWORD_TOKEN: