Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
14293443
Commit
14293443
authored
Nov 06, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-18903
parents
86a1c962
891c7120
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
14 deletions
+35
-14
pom.xml
ci/images/releasescripts/pom.xml
+4
-0
BintrayService.java
...ring/concourse/releasescripts/bintray/BintrayService.java
+24
-14
BintrayServiceTests.java
...concourse/releasescripts/bintray/BintrayServiceTests.java
+7
-0
No files found.
ci/images/releasescripts/pom.xml
View file @
14293443
...
@@ -44,6 +44,10 @@
...
@@ -44,6 +44,10 @@
<groupId>
com.fasterxml.jackson.module
</groupId>
<groupId>
com.fasterxml.jackson.module
</groupId>
<artifactId>
jackson-module-parameter-names
</artifactId>
<artifactId>
jackson-module-parameter-names
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.awaitility
</groupId>
<artifactId>
awaitility
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java
View file @
14293443
...
@@ -17,19 +17,25 @@
...
@@ -17,19 +17,25 @@
package
io
.
spring
.
concourse
.
releasescripts
.
bintray
;
package
io
.
spring
.
concourse
.
releasescripts
.
bintray
;
import
java.net.URI
;
import
java.net.URI
;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
import
io.spring.concourse.releasescripts.ReleaseInfo
;
import
io.spring.concourse.releasescripts.ReleaseInfo
;
import
io.spring.concourse.releasescripts.sonatype.SonatypeProperties
;
import
io.spring.concourse.releasescripts.sonatype.SonatypeProperties
;
import
io.spring.concourse.releasescripts.sonatype.SonatypeService
;
import
io.spring.concourse.releasescripts.sonatype.SonatypeService
;
import
io.spring.concourse.releasescripts.system.ConsoleLogger
;
import
io.spring.concourse.releasescripts.system.ConsoleLogger
;
import
org.awaitility.core.ConditionTimeoutException
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.RequestEntity
;
import
org.springframework.http.RequestEntity
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.HttpClientErrorException
;
import
org.springframework.web.client.HttpClientErrorException
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
static
org
.
awaitility
.
Awaitility
.
waitAtMost
;
/**
/**
* Central class for interacting with Bintray's REST API.
* Central class for interacting with Bintray's REST API.
*
*
...
@@ -64,25 +70,29 @@ public class BintrayService {
...
@@ -64,25 +70,29 @@ public class BintrayService {
}
}
public
boolean
isDistributionComplete
(
ReleaseInfo
releaseInfo
)
{
public
boolean
isDistributionComplete
(
ReleaseInfo
releaseInfo
)
{
RequestEntity
<
Void
>
publishedFilesRequest
=
getRequest
(
releaseInfo
,
0
);
RequestEntity
<
Void
>
allFilesRequest
=
getRequest
(
releaseInfo
,
1
);
RequestEntity
<
Void
>
allFilesRequest
=
getRequest
(
releaseInfo
,
1
);
Object
[]
allFiles
=
this
.
restTemplate
.
exchange
(
allFilesRequest
,
Object
[].
class
).
getBody
();
Object
[]
allFiles
=
waitAtMost
(
5
,
TimeUnit
.
MINUTES
).
with
().
pollDelay
(
20
,
TimeUnit
.
SECONDS
).
until
(()
->
{
int
count
=
0
;
while
(
count
<
120
)
{
Object
[]
publishedFiles
=
this
.
restTemplate
.
exchange
(
publishedFilesRequest
,
Object
[].
class
).
getBody
();
int
unpublished
=
allFiles
.
length
-
publishedFiles
.
length
;
if
(
unpublished
==
0
)
{
return
true
;
}
count
++;
try
{
try
{
Thread
.
sleep
(
20000
);
return
this
.
restTemplate
.
exchange
(
allFilesRequest
,
Object
[].
class
).
getBody
(
);
}
}
catch
(
InterruptedException
e
)
{
catch
(
HttpClientErrorException
ex
)
{
if
(
ex
.
getStatusCode
()
!=
HttpStatus
.
NOT_FOUND
)
{
throw
ex
;
}
return
null
;
}
}
},
Objects:
:
nonNull
);
RequestEntity
<
Void
>
publishedFilesRequest
=
getRequest
(
releaseInfo
,
0
);
try
{
waitAtMost
(
40
,
TimeUnit
.
MINUTES
).
with
().
pollDelay
(
20
,
TimeUnit
.
SECONDS
).
until
(()
->
{
Object
[]
publishedFiles
=
this
.
restTemplate
.
exchange
(
publishedFilesRequest
,
Object
[].
class
).
getBody
();
return
allFiles
.
length
==
publishedFiles
.
length
;
});
}
catch
(
ConditionTimeoutException
ex
)
{
return
false
;
}
}
return
fals
e
;
return
tru
e
;
}
}
private
RequestEntity
<
Void
>
getRequest
(
ReleaseInfo
releaseInfo
,
int
includeUnpublished
)
{
private
RequestEntity
<
Void
>
getRequest
(
ReleaseInfo
releaseInfo
,
int
includeUnpublished
)
{
...
...
ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/bintray/BintrayServiceTests.java
View file @
14293443
...
@@ -28,6 +28,7 @@ import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
...
@@ -28,6 +28,7 @@ import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.client.ExpectedCount
;
import
org.springframework.test.web.client.ExpectedCount
;
import
org.springframework.test.web.client.MockRestServiceServer
;
import
org.springframework.test.web.client.MockRestServiceServer
;
...
@@ -40,6 +41,7 @@ import static org.springframework.test.web.client.match.MockRestRequestMatchers.
...
@@ -40,6 +41,7 @@ import static org.springframework.test.web.client.match.MockRestRequestMatchers.
import
static
org
.
springframework
.
test
.
web
.
client
.
match
.
MockRestRequestMatchers
.
header
;
import
static
org
.
springframework
.
test
.
web
.
client
.
match
.
MockRestRequestMatchers
.
header
;
import
static
org
.
springframework
.
test
.
web
.
client
.
match
.
MockRestRequestMatchers
.
method
;
import
static
org
.
springframework
.
test
.
web
.
client
.
match
.
MockRestRequestMatchers
.
method
;
import
static
org
.
springframework
.
test
.
web
.
client
.
match
.
MockRestRequestMatchers
.
requestTo
;
import
static
org
.
springframework
.
test
.
web
.
client
.
match
.
MockRestRequestMatchers
.
requestTo
;
import
static
org
.
springframework
.
test
.
web
.
client
.
response
.
MockRestResponseCreators
.
withStatus
;
import
static
org
.
springframework
.
test
.
web
.
client
.
response
.
MockRestResponseCreators
.
withSuccess
;
import
static
org
.
springframework
.
test
.
web
.
client
.
response
.
MockRestResponseCreators
.
withSuccess
;
/**
/**
...
@@ -73,6 +75,11 @@ class BintrayServiceTests {
...
@@ -73,6 +75,11 @@ class BintrayServiceTests {
@Test
@Test
void
isDistributionComplete
()
throws
Exception
{
void
isDistributionComplete
()
throws
Exception
{
this
.
server
.
expect
(
requestTo
(
String
.
format
(
"https://api.bintray.com/packages/%s/%s/%s/versions/%s/files?include_unpublished=%s"
,
this
.
properties
.
getSubject
(),
this
.
properties
.
getRepo
(),
"example"
,
"1.1.0.RELEASE"
,
1
)))
.
andRespond
(
withStatus
(
HttpStatus
.
NOT_FOUND
));
setupGetPackageFiles
(
1
,
"all-package-files.json"
);
setupGetPackageFiles
(
1
,
"all-package-files.json"
);
setupGetPackageFiles
(
0
,
"published-files.json"
);
setupGetPackageFiles
(
0
,
"published-files.json"
);
setupGetPackageFiles
(
0
,
"all-package-files.json"
);
setupGetPackageFiles
(
0
,
"all-package-files.json"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment