Skip to content

Commit bc35945

Browse files
committed
Concourse pipeline
1 parent 0ff17df commit bc35945

19 files changed

+570
-8
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PATH_add scripts

buildSrc/src/main/groovy/io.pivotal.cfenv.java-conventions.gradle

+65-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import org.gradle.api.tasks.testing.TestDescriptor
2+
import org.gradle.api.tasks.testing.TestOutputEvent
3+
import org.gradle.api.tasks.testing.TestResult
4+
5+
import java.util.concurrent.ConcurrentHashMap
6+
17
plugins {
28
id 'java-library'
39
id 'maven-publish'
@@ -36,15 +42,70 @@ test {
3642
}
3743

3844
afterEvaluate { Project project ->
39-
tasks.withType(Test).forEach { Test test ->
40-
def jmockit = test.classpath.find { it.name.contains("jmockit") }
41-
if (jmockit) {
42-
test.jvmArgs "-javaagent:${jmockit.absolutePath}"
45+
if (project.description == null || project.description.isEmpty()) {
46+
throw new InvalidUserDataException("A project description is required for publishing to maven central")
47+
}
48+
49+
tasks.withType(Test).forEach { Test task ->
50+
task.with {
51+
def jmockit = classpath.find { it.name.contains("jmockit") }
52+
if (jmockit) {
53+
jvmArgs "-javaagent:${jmockit.absolutePath}"
54+
}
55+
56+
testLogging {
57+
exceptionFormat = "full"
58+
events = ["passed", "skipped", "failed"]
59+
showStandardStreams = !project.onlyShowStandardStreamsOnTestFailure
60+
}
61+
62+
if (project.onlyShowStandardStreamsOnTestFailure) {
63+
Map<String, StringBuilder> testOutput = new ConcurrentHashMap<>()
64+
65+
onOutput { TestDescriptor descriptor, TestOutputEvent event ->
66+
testOutput.compute(descriptor.displayName, { k, v ->
67+
v == null ? new StringBuilder(event.message) : v.append(event.message)
68+
})
69+
}
70+
71+
afterTest { TestDescriptor descriptor, TestResult result ->
72+
if (result.resultType == TestResult.ResultType.FAILURE && testOutput.containsKey(descriptor.displayName)) {
73+
logger.lifecycle("\n\n${testOutput.get(descriptor.displayName)}")
74+
testOutput.remove(descriptor.displayName)
75+
}
76+
}
77+
}
78+
79+
// print failed tests after the execution
80+
def failedTests = []
81+
afterTest { test, result ->
82+
if (result.resultType == TestResult.ResultType.FAILURE) {
83+
failedTests << test
84+
}
85+
}
86+
87+
// create a summary after the execution
88+
afterSuite { desc, result ->
89+
if (!desc.parent) {
90+
println "\nTest result: ${result.resultType}"
91+
println "Test summary: ${result.testCount} tests, " +
92+
"${result.successfulTestCount} succeeded, " +
93+
"${result.failedTestCount} failed, " +
94+
"${result.skippedTestCount} skipped"
95+
96+
failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
97+
}
98+
}
4399
}
44100
}
45101
}
46102

47103
publishing {
104+
repositories {
105+
maven {
106+
url = project.properties.getOrDefault('publicationRepository', "${System.getenv('HOME')}/.m2/repository")
107+
}
108+
}
48109
publications {
49110
mavenJava(MavenPublication) {
50111
suppressAllPomMetadataWarnings()

ci/config-concourse.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
artifactory-server: https://repo.spring.io
2+
build-name: java-cfenv
3+
github-repo: https://github.com/pivotal-cf/java-cfenv
4+
scs-slack-failure-channel: "#spring-cloud-services"

ci/config/checkstyle.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
~ Copyright 2002-2019 the original author or authors.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<!DOCTYPE module PUBLIC
19+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
20+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
21+
22+
<module name="Checker">
23+
<module name="Header">
24+
<property name="headerFile" value="ci/config/license.header"/>
25+
<property name="ignoreLines" value="2"/>
26+
</module>
27+
</module>

ci/config/license.header

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/

ci/config/release-scripts.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
logging:
2+
level:
3+
io.spring.concourse: DEBUG
4+
spring:
5+
main:
6+
banner-mode: off
7+
sonatype:
8+
exclude:
9+
- 'build-info\.json'
10+
- '.*\.zip'

ci/images/java-cfenv-ci/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM harbor-repo.vmware.com/dockerhub-proxy-cache/library/ubuntu:bionic
2+
3+
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates net-tools git curl
4+
RUN rm -rf /var/lib/apt/lists/*
5+
6+
ENV JAVA_HOME /opt/openjdk
7+
ENV PATH $JAVA_HOME/bin:$PATH
8+
RUN mkdir -p /opt/openjdk && \
9+
cd /opt/openjdk && \
10+
curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz | tar xz --strip-components=1
11+
12+
ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh /opt/
13+
ADD https://repo.spring.io/libs-release/io/spring/concourse/releasescripts/concourse-release-scripts/0.3.3/concourse-release-scripts-0.3.3.jar /opt/
14+

ci/pipeline.yml

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
---
2+
aliases:
3+
- &slack-failure-notification
4+
put: alert
5+
params:
6+
icon_emoji: ":animal-1252:"
7+
username: concourse
8+
channel: ((scs-slack-failure-channel))
9+
text: <!here> Build <${ATC_EXTERNAL_URL}/builds/$BUILD_ID|$BUILD_NAME> of job $BUILD_JOB_NAME in the $BUILD_PIPELINE_NAME pipeline has failed!
10+
11+
jobs:
12+
- name: build-ci-images
13+
plan:
14+
- get: ci-images-git-repo
15+
trigger: true
16+
- put: java-cfenv-ci-image
17+
params:
18+
build: ci-images-git-repo/ci/images/java-cfenv-ci
19+
get_params:
20+
skip_download: "true"
21+
22+
- name: build
23+
serial: true
24+
public: true
25+
plan:
26+
- get: git-repo
27+
trigger: true
28+
- task: build-project
29+
file: git-repo/ci/tasks/build-project.yml
30+
- put: artifactory-repo
31+
params: &artifactory-params
32+
signing_key: ((signing-key))
33+
signing_passphrase: ((signing-passphrase))
34+
repo: libs-snapshot-local
35+
folder: distribution-repository
36+
build_uri: "${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}"
37+
build_number: "${BUILD_PIPELINE_NAME}-${BUILD_JOB_NAME}-${BUILD_NAME}"
38+
disable_checksum_uploads: true
39+
on_failure:
40+
*slack-failure-notification
41+
42+
- name: stage-milestone
43+
serial: true
44+
plan:
45+
- get: git-repo
46+
passed: [build]
47+
- task: stage
48+
file: git-repo/ci/tasks/stage.yml
49+
vars:
50+
release-type: M
51+
- put: artifactory-repo
52+
params:
53+
<<: *artifactory-params
54+
repo: libs-staging-local
55+
- put: git-repo-staging
56+
params:
57+
repository: stage-git-repo
58+
59+
- name: stage-rc
60+
serial: true
61+
plan:
62+
- get: git-repo
63+
passed: [build]
64+
- task: stage
65+
file: git-repo/ci/tasks/stage.yml
66+
vars:
67+
release-type: RC
68+
- put: artifactory-repo
69+
params:
70+
<<: *artifactory-params
71+
repo: libs-staging-local
72+
- put: git-repo-staging
73+
params:
74+
repository: stage-git-repo
75+
76+
- name: stage-release
77+
serial: true
78+
plan:
79+
- get: git-repo
80+
passed: [build]
81+
- task: stage
82+
file: git-repo/ci/tasks/stage.yml
83+
vars:
84+
release-type: RELEASE
85+
- put: artifactory-repo
86+
params:
87+
<<: *artifactory-params
88+
repo: libs-staging-local
89+
- put: git-repo-staging
90+
params:
91+
repository: stage-git-repo
92+
93+
- name: promote-milestone
94+
serial: true
95+
plan:
96+
- get: git-repo
97+
- get: artifactory-repo
98+
passed: [stage-milestone]
99+
params:
100+
save_build_info: true
101+
- task: promote
102+
file: git-repo/ci/tasks/promote.yml
103+
vars:
104+
release-type: M
105+
106+
- name: promote-rc
107+
serial: true
108+
plan:
109+
- in_parallel:
110+
- get: git-repo
111+
- get: artifactory-repo
112+
passed: [stage-rc]
113+
params:
114+
save_build_info: true
115+
- task: promote
116+
file: git-repo/ci/tasks/promote.yml
117+
vars:
118+
release-type: RC
119+
120+
- name: promote-release
121+
serial: true
122+
plan:
123+
- in_parallel:
124+
- get: git-repo
125+
- get: artifactory-repo
126+
passed: [stage-release]
127+
params:
128+
save_build_info: true
129+
- task: promote
130+
file: git-repo/ci/tasks/promote.yml
131+
vars:
132+
release-type: RELEASE
133+
134+
- name: sync-to-maven-central
135+
serial: true
136+
plan:
137+
- in_parallel:
138+
- get: git-repo
139+
- get: artifactory-repo
140+
passed: [promote-release]
141+
params:
142+
save_build_info: true
143+
- task: sync-to-maven-central
144+
file: git-repo/ci/tasks/sync-to-maven-central.yml
145+
146+
resource_types:
147+
- name: artifactory-resource
148+
type: registry-image
149+
source:
150+
repository: ((dockerhub-mirror-registry))/springio/artifactory-resource
151+
tag: latest
152+
- name: slack-notification
153+
type: registry-image
154+
source:
155+
repository: ((dockerhub-mirror-registry))/cfcommunity/slack-notification-resource
156+
tag: latest
157+
158+
resources:
159+
- name: git-repo
160+
type: git
161+
source:
162+
uri: ((github-repo))
163+
username: ((github-username))
164+
password: ((github-password))
165+
branch: ((branch))
166+
ignore_paths: ["ci/images/*"]
167+
fetch_tags: true
168+
169+
- name: git-repo-staging
170+
type: git
171+
source:
172+
uri: ((github-repo))
173+
username: ((github-username))
174+
password: ((github-password))
175+
branch: ((github-username))/staging
176+
177+
- name: ci-images-git-repo
178+
type: git
179+
source:
180+
uri: ((github-repo))
181+
branch: ((branch))
182+
paths: ["ci/images/*"]
183+
184+
- name: java-cfenv-ci-image
185+
type: docker-image
186+
source:
187+
repository: ((corporate-harbor-registry))/((docker-hub-organization))/java-cfenv-ci
188+
username: ((corporate-harbor-robot-account.username))
189+
password: ((corporate-harbor-robot-account.password))
190+
191+
- name: artifactory-repo
192+
type: artifactory-resource
193+
source:
194+
uri: ((artifactory-server))
195+
username: ((scs-artifactory-username))
196+
password: ((scs-artifactory-password))
197+
build_name: ((build-name))
198+
199+
- name: alert
200+
type: slack-notification
201+
source:
202+
url: ((scs-slack-webhook))
203+
204+
groups:
205+
- name: "build"
206+
jobs:
207+
- build
208+
- name: "milestone"
209+
jobs:
210+
- stage-milestone
211+
- promote-milestone
212+
- name: "rc"
213+
jobs:
214+
- stage-rc
215+
- promote-rc
216+
- name: "release"
217+
jobs:
218+
- stage-release
219+
- promote-release
220+
- sync-to-maven-central
221+
- name: "ci-images"
222+
jobs:
223+
- build-ci-images

0 commit comments

Comments
 (0)