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
dbda2d0b
Commit
dbda2d0b
authored
Jun 12, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve release script logging
Improve logging and fix a few issue with the release script. See gh-21474
parent
ce011ca3
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
99 additions
and
63 deletions
+99
-63
ArtifactoryService.java
...course/releasescripts/artifactory/ArtifactoryService.java
+16
-8
BuildInfoResponse.java
...releasescripts/artifactory/payload/BuildInfoResponse.java
+3
-2
BintrayService.java
...ring/concourse/releasescripts/bintray/BintrayService.java
+26
-9
CommandProcessor.java
...ng/concourse/releasescripts/command/CommandProcessor.java
+10
-2
DistributeCommand.java
...g/concourse/releasescripts/command/DistributeCommand.java
+17
-1
PromoteCommand.java
...ring/concourse/releasescripts/command/PromoteCommand.java
+5
-0
PublishGradlePlugin.java
...concourse/releasescripts/command/PublishGradlePlugin.java
+5
-0
SyncToCentralCommand.java
...oncourse/releasescripts/command/SyncToCentralCommand.java
+5
-0
SonatypeService.java
...ng/concourse/releasescripts/sonatype/SonatypeService.java
+5
-4
ConsoleLogger.java
...spring/concourse/releasescripts/system/ConsoleLogger.java
+0
-32
application.properties
.../releasescripts/src/main/resources/application.properties
+2
-1
ArtifactoryServiceTests.java
...e/releasescripts/artifactory/ArtifactoryServiceTests.java
+2
-1
promote.sh
ci/scripts/promote.sh
+3
-3
No files found.
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java
View file @
dbda2d0b
...
...
@@ -25,7 +25,8 @@ import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse;
import
io.spring.concourse.releasescripts.artifactory.payload.DistributionRequest
;
import
io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest
;
import
io.spring.concourse.releasescripts.bintray.BintrayService
;
import
io.spring.concourse.releasescripts.system.ConsoleLogger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.MediaType
;
...
...
@@ -44,6 +45,8 @@ import org.springframework.web.client.RestTemplate;
@Component
public
class
ArtifactoryService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ArtifactoryService
.
class
);
private
static
final
String
ARTIFACTORY_URL
=
"https://repo.spring.io"
;
private
static
final
String
PROMOTION_URL
=
ARTIFACTORY_URL
+
"/api/build/promote/"
;
...
...
@@ -58,8 +61,6 @@ public class ArtifactoryService {
private
final
BintrayService
bintrayService
;
private
static
final
ConsoleLogger
console
=
new
ConsoleLogger
();
public
ArtifactoryService
(
RestTemplateBuilder
builder
,
ArtifactoryProperties
artifactoryProperties
,
BintrayService
bintrayService
)
{
this
.
bintrayService
=
bintrayService
;
...
...
@@ -80,20 +81,21 @@ public class ArtifactoryService {
PromotionRequest
request
=
getPromotionRequest
(
targetRepo
);
String
buildName
=
releaseInfo
.
getBuildName
();
String
buildNumber
=
releaseInfo
.
getBuildNumber
();
console
.
log
(
"Promoting "
+
buildName
+
"/"
+
buildNumber
+
" to "
+
request
.
getTargetRepo
());
logger
.
info
(
"Promoting "
+
buildName
+
"/"
+
buildNumber
+
" to "
+
request
.
getTargetRepo
());
RequestEntity
<
PromotionRequest
>
requestEntity
=
RequestEntity
.
post
(
URI
.
create
(
PROMOTION_URL
+
buildName
+
"/"
+
buildNumber
)).
contentType
(
MediaType
.
APPLICATION_JSON
)
.
body
(
request
);
try
{
this
.
restTemplate
.
exchange
(
requestEntity
,
String
.
class
);
logger
.
debug
(
"Promotion complete"
);
}
catch
(
HttpClientErrorException
ex
)
{
boolean
isAlreadyPromoted
=
isAlreadyPromoted
(
buildName
,
buildNumber
,
request
.
getTargetRepo
());
if
(
isAlreadyPromoted
)
{
console
.
log
(
"Already promoted."
);
logger
.
info
(
"Already promoted."
);
}
else
{
console
.
log
(
"Promotion failed."
);
logger
.
info
(
"Promotion failed."
);
throw
ex
;
}
}
...
...
@@ -101,12 +103,15 @@ public class ArtifactoryService {
private
boolean
isAlreadyPromoted
(
String
buildName
,
String
buildNumber
,
String
targetRepo
)
{
try
{
logger
.
debug
(
"Checking if alreay promoted"
);
ResponseEntity
<
BuildInfoResponse
>
entity
=
this
.
restTemplate
.
getForEntity
(
BUILD_INFO_URL
+
buildName
+
"/"
+
buildNumber
,
BuildInfoResponse
.
class
);
BuildInfoResponse
.
Status
status
=
entity
.
getBody
().
getBuildInfo
().
getStatuses
()[
0
];
logger
.
debug
(
"Reutned repository "
+
status
.
getRepository
()
+
" expecting "
+
targetRepo
);
return
status
.
getRepository
().
equals
(
targetRepo
);
}
catch
(
HttpClientErrorException
ex
)
{
logger
.
debug
(
"Client error, assuming not promoted"
);
return
false
;
}
}
...
...
@@ -118,8 +123,10 @@ public class ArtifactoryService {
* @param artifactDigests the artifact digests
*/
public
void
distribute
(
String
sourceRepo
,
ReleaseInfo
releaseInfo
,
Set
<
String
>
artifactDigests
)
{
logger
.
debug
(
"Attempting distribute via Artifactory"
);
if
(
this
.
bintrayService
.
isDistributionComplete
(
releaseInfo
,
artifactDigests
,
Duration
.
ofMinutes
(
2
)))
{
console
.
log
(
"Distribution already complete"
);
logger
.
info
(
"Distribution already complete"
);
return
;
}
DistributionRequest
request
=
new
DistributionRequest
(
new
String
[]
{
sourceRepo
});
RequestEntity
<
DistributionRequest
>
requestEntity
=
RequestEntity
...
...
@@ -127,9 +134,10 @@ public class ArtifactoryService {
.
contentType
(
MediaType
.
APPLICATION_JSON
).
body
(
request
);
try
{
this
.
restTemplate
.
exchange
(
requestEntity
,
Object
.
class
);
logger
.
debug
(
"Distribution call completed"
);
}
catch
(
HttpClientErrorException
ex
)
{
console
.
log
(
"Failed to distribute."
);
logger
.
info
(
"Failed to distribute."
);
throw
ex
;
}
if
(!
this
.
bintrayService
.
isDistributionComplete
(
releaseInfo
,
artifactDigests
,
Duration
.
ofMinutes
(
60
)))
{
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/payload/BuildInfoResponse.java
View file @
dbda2d0b
...
...
@@ -18,6 +18,7 @@ package io.spring.concourse.releasescripts.artifactory.payload;
import
java.util.Arrays
;
import
java.util.Set
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -91,11 +92,11 @@ public class BuildInfoResponse {
}
public
Set
<
String
>
getArtifactDigests
()
{
public
Set
<
String
>
getArtifactDigests
(
Predicate
<
Artifact
>
predicate
)
{
return
Arrays
.
stream
(
this
.
modules
).
flatMap
((
module
)
->
{
Artifact
[]
artifacts
=
module
.
getArtifacts
();
return
(
artifacts
!=
null
)
?
Arrays
.
stream
(
artifacts
)
:
Stream
.
empty
();
}).
map
(
Artifact:
:
getSha256
).
collect
(
Collectors
.
toSet
());
}).
filter
(
predicate
).
map
(
Artifact:
:
getSha256
).
collect
(
Collectors
.
toSet
());
}
}
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java
View file @
dbda2d0b
...
...
@@ -24,8 +24,9 @@ import java.util.Set;
import
io.spring.concourse.releasescripts.ReleaseInfo
;
import
io.spring.concourse.releasescripts.sonatype.SonatypeProperties
;
import
io.spring.concourse.releasescripts.sonatype.SonatypeService
;
import
io.spring.concourse.releasescripts.system.ConsoleLogger
;
import
org.awaitility.core.ConditionTimeoutException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.MediaType
;
...
...
@@ -45,6 +46,8 @@ import static org.awaitility.Awaitility.waitAtMost;
@Component
public
class
BintrayService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BintrayService
.
class
);
private
static
final
String
BINTRAY_URL
=
"https://api.bintray.com/"
;
private
static
final
String
GRADLE_PLUGIN_REQUEST
=
"[ { \"name\": \"gradle-plugin\", \"values\": [\"org.springframework.boot:org.springframework.boot:spring-boot-gradle-plugin\"] } ]"
;
...
...
@@ -57,8 +60,6 @@ public class BintrayService {
private
final
SonatypeService
sonatypeService
;
private
static
final
ConsoleLogger
console
=
new
ConsoleLogger
();
public
BintrayService
(
RestTemplateBuilder
builder
,
BintrayProperties
bintrayProperties
,
SonatypeProperties
sonatypeProperties
,
SonatypeService
sonatypeService
)
{
this
.
bintrayProperties
=
bintrayProperties
;
...
...
@@ -77,15 +78,18 @@ public class BintrayService {
}
public
boolean
isDistributionComplete
(
ReleaseInfo
releaseInfo
,
Set
<
String
>
requiredDigets
,
Duration
timeout
,
Duration
pollDelay
)
{
Duration
pollInterval
)
{
logger
.
debug
(
"Checking if distribution is complete"
);
RequestEntity
<
Void
>
request
=
getRequest
(
releaseInfo
,
0
);
try
{
waitAtMost
(
timeout
).
with
().
pollDelay
(
pollDelay
).
until
(()
->
{
waitAtMost
(
timeout
).
with
().
pollDelay
(
Duration
.
ZERO
).
pollInterval
(
pollInterval
).
until
(()
->
{
logger
.
debug
(
"Checking bintray"
);
PackageFile
[]
published
=
this
.
restTemplate
.
exchange
(
request
,
PackageFile
[].
class
).
getBody
();
return
hasPublishedAll
(
published
,
requiredDigets
);
});
}
catch
(
ConditionTimeoutException
ex
)
{
logger
.
debug
(
"Timeout checking bintray"
);
return
false
;
}
return
true
;
...
...
@@ -93,13 +97,22 @@ public class BintrayService {
private
boolean
hasPublishedAll
(
PackageFile
[]
published
,
Set
<
String
>
requiredDigets
)
{
if
(
published
==
null
||
published
.
length
==
0
)
{
logger
.
debug
(
"Bintray returned no published files"
);
return
false
;
}
Set
<
String
>
remaining
=
new
HashSet
<>(
requiredDigets
);
for
(
PackageFile
publishedFile
:
published
)
{
logger
.
debug
(
"Found published file "
+
publishedFile
.
getName
()
+
" with digest "
+
publishedFile
.
getSha256
());
remaining
.
remove
(
publishedFile
.
getSha256
());
}
return
remaining
.
isEmpty
();
if
(
remaining
.
isEmpty
())
{
logger
.
debug
(
"Found all required digests"
);
return
true
;
}
logger
.
debug
(
"Some digests have not been published:"
);
remaining
.
forEach
(
logger:
:
debug
);
return
false
;
}
private
RequestEntity
<
Void
>
getRequest
(
ReleaseInfo
releaseInfo
,
int
includeUnpublished
)
{
...
...
@@ -113,6 +126,7 @@ public class BintrayService {
* @param releaseInfo the release information
*/
public
void
publishGradlePlugin
(
ReleaseInfo
releaseInfo
)
{
logger
.
debug
(
"Publishing Gradle Pluging"
);
RequestEntity
<
String
>
requestEntity
=
RequestEntity
.
post
(
URI
.
create
(
BINTRAY_URL
+
"packages/"
+
this
.
bintrayProperties
.
getSubject
()
+
"/"
+
this
.
bintrayProperties
.
getRepo
()
+
"/"
+
releaseInfo
.
getGroupId
()
+
"/versions/"
...
...
@@ -120,9 +134,10 @@ public class BintrayService {
.
contentType
(
MediaType
.
APPLICATION_JSON
).
body
(
GRADLE_PLUGIN_REQUEST
);
try
{
this
.
restTemplate
.
exchange
(
requestEntity
,
Object
.
class
);
logger
.
debug
(
"Publishing Gradle Pluging complete"
);
}
catch
(
HttpClientErrorException
ex
)
{
console
.
log
(
"Failed to add attribute to gradle plugin."
);
logger
.
info
(
"Failed to add attribute to gradle plugin."
);
throw
ex
;
}
}
...
...
@@ -132,8 +147,9 @@ public class BintrayService {
* @param releaseInfo the release information
*/
public
void
syncToMavenCentral
(
ReleaseInfo
releaseInfo
)
{
console
.
log
(
"Calling Bintray to sync to Sonatype"
);
logger
.
info
(
"Calling Bintray to sync to Sonatype"
);
if
(
this
.
sonatypeService
.
artifactsPublished
(
releaseInfo
))
{
logger
.
info
(
"Artifacts already published"
);
return
;
}
RequestEntity
<
SonatypeProperties
>
requestEntity
=
RequestEntity
...
...
@@ -143,9 +159,10 @@ public class BintrayService {
.
contentType
(
MediaType
.
APPLICATION_JSON
).
body
(
this
.
sonatypeProperties
);
try
{
this
.
restTemplate
.
exchange
(
requestEntity
,
Object
.
class
);
logger
.
debug
(
"Sync complete"
);
}
catch
(
HttpClientErrorException
ex
)
{
console
.
log
(
"Failed to sync."
);
logger
.
info
(
"Failed to sync."
);
throw
ex
;
}
}
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/CommandProcessor.java
View file @
dbda2d0b
...
...
@@ -19,6 +19,9 @@ package io.spring.concourse.releasescripts.command;
import
java.util.Collections
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.stereotype.Component
;
...
...
@@ -32,6 +35,8 @@ import org.springframework.util.Assert;
@Component
public
class
CommandProcessor
implements
ApplicationRunner
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CommandProcessor
.
class
);
private
final
List
<
Command
>
commands
;
public
CommandProcessor
(
List
<
Command
>
commands
)
{
...
...
@@ -40,11 +45,14 @@ public class CommandProcessor implements ApplicationRunner {
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
logger
.
debug
(
"Running command processor"
);
List
<
String
>
nonOptionArgs
=
args
.
getNonOptionArgs
();
Assert
.
state
(!
nonOptionArgs
.
isEmpty
(),
"No command argument specified"
);
String
request
=
nonOptionArgs
.
get
(
0
);
this
.
commands
.
stream
().
filter
((
c
)
->
c
.
getName
().
equals
(
request
)).
findFirst
()
.
orElseThrow
(()
->
new
IllegalStateException
(
"Unknown command '"
+
request
+
"'"
)).
run
(
args
);
Command
command
=
this
.
commands
.
stream
().
filter
((
candidate
)
->
candidate
.
getName
().
equals
(
request
)).
findFirst
()
.
orElseThrow
(()
->
new
IllegalStateException
(
"Unknown command '"
+
request
+
"'"
));
logger
.
debug
(
"Found command "
+
command
.
getClass
().
getName
());
command
.
run
(
args
);
}
}
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/DistributeCommand.java
View file @
dbda2d0b
...
...
@@ -26,7 +26,11 @@ import io.spring.concourse.releasescripts.ReleaseInfo;
import
io.spring.concourse.releasescripts.ReleaseType
;
import
io.spring.concourse.releasescripts.artifactory.ArtifactoryService
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.Artifact
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.BuildInfo
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse.Module
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.stereotype.Component
;
...
...
@@ -40,6 +44,8 @@ import org.springframework.util.Assert;
@Component
public
class
DistributeCommand
implements
Command
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DistributeCommand
.
class
);
private
final
ArtifactoryService
artifactoryService
;
private
final
ObjectMapper
objectMapper
;
...
...
@@ -51,20 +57,30 @@ public class DistributeCommand implements Command {
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
logger
.
debug
(
"Running 'distribute' command"
);
List
<
String
>
nonOptionArgs
=
args
.
getNonOptionArgs
();
Assert
.
state
(!
nonOptionArgs
.
isEmpty
(),
"No command argument specified"
);
Assert
.
state
(
nonOptionArgs
.
size
()
==
3
,
"Release type or build info not specified"
);
String
releaseType
=
nonOptionArgs
.
get
(
1
);
ReleaseType
type
=
ReleaseType
.
from
(
releaseType
);
if
(!
ReleaseType
.
RELEASE
.
equals
(
type
))
{
logger
.
info
(
"Skipping distribution of "
+
type
+
" type"
);
return
;
}
String
buildInfoLocation
=
nonOptionArgs
.
get
(
2
);
logger
.
debug
(
"Loading build-info from "
+
buildInfoLocation
);
byte
[]
content
=
Files
.
readAllBytes
(
new
File
(
buildInfoLocation
).
toPath
());
BuildInfoResponse
buildInfoResponse
=
this
.
objectMapper
.
readValue
(
content
,
BuildInfoResponse
.
class
);
BuildInfo
buildInfo
=
buildInfoResponse
.
getBuildInfo
();
Set
<
String
>
artifactDigests
=
buildInfo
.
getArtifactDigests
();
logger
.
debug
(
"Loading build info:"
);
for
(
Module
module
:
buildInfo
.
getModules
())
{
logger
.
debug
(
module
.
getId
());
for
(
Artifact
artifact
:
module
.
getArtifacts
())
{
logger
.
debug
(
artifact
.
getSha256
()
+
" "
+
artifact
.
getName
());
}
}
ReleaseInfo
releaseInfo
=
ReleaseInfo
.
from
(
buildInfo
);
Set
<
String
>
artifactDigests
=
buildInfo
.
getArtifactDigests
((
artifact
)
->
!
artifact
.
getName
().
endsWith
(
".zip"
));
this
.
artifactoryService
.
distribute
(
type
.
getRepo
(),
releaseInfo
,
artifactDigests
);
}
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PromoteCommand.java
View file @
dbda2d0b
...
...
@@ -25,6 +25,8 @@ import io.spring.concourse.releasescripts.ReleaseInfo;
import
io.spring.concourse.releasescripts.ReleaseType
;
import
io.spring.concourse.releasescripts.artifactory.ArtifactoryService
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.stereotype.Component
;
...
...
@@ -38,6 +40,8 @@ import org.springframework.util.Assert;
@Component
public
class
PromoteCommand
implements
Command
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PromoteCommand
.
class
);
private
final
ArtifactoryService
service
;
private
final
ObjectMapper
objectMapper
;
...
...
@@ -49,6 +53,7 @@ public class PromoteCommand implements Command {
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
logger
.
debug
(
"Running 'promote' command"
);
List
<
String
>
nonOptionArgs
=
args
.
getNonOptionArgs
();
Assert
.
state
(!
nonOptionArgs
.
isEmpty
(),
"No command argument specified"
);
Assert
.
state
(
nonOptionArgs
.
size
()
==
3
,
"Release type or build info location not specified"
);
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/PublishGradlePlugin.java
View file @
dbda2d0b
...
...
@@ -25,6 +25,8 @@ import io.spring.concourse.releasescripts.ReleaseInfo;
import
io.spring.concourse.releasescripts.ReleaseType
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse
;
import
io.spring.concourse.releasescripts.bintray.BintrayService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.stereotype.Component
;
...
...
@@ -38,6 +40,8 @@ import org.springframework.util.Assert;
@Component
public
class
PublishGradlePlugin
implements
Command
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PublishGradlePlugin
.
class
);
private
static
final
String
PUBLISH_GRADLE_PLUGIN_COMMAND
=
"publishGradlePlugin"
;
private
final
BintrayService
service
;
...
...
@@ -56,6 +60,7 @@ public class PublishGradlePlugin implements Command {
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
logger
.
debug
(
"Running 'publish gradle' command"
);
List
<
String
>
nonOptionArgs
=
args
.
getNonOptionArgs
();
Assert
.
state
(!
nonOptionArgs
.
isEmpty
(),
"No command argument specified"
);
Assert
.
state
(
nonOptionArgs
.
size
()
==
3
,
"Release type or build info not specified"
);
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/command/SyncToCentralCommand.java
View file @
dbda2d0b
...
...
@@ -25,6 +25,8 @@ import io.spring.concourse.releasescripts.ReleaseInfo;
import
io.spring.concourse.releasescripts.ReleaseType
;
import
io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse
;
import
io.spring.concourse.releasescripts.bintray.BintrayService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.stereotype.Component
;
...
...
@@ -38,6 +40,8 @@ import org.springframework.util.Assert;
@Component
public
class
SyncToCentralCommand
implements
Command
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SyncToCentralCommand
.
class
);
private
static
final
String
SYNC_TO_CENTRAL_COMMAND
=
"syncToCentral"
;
private
final
BintrayService
service
;
...
...
@@ -56,6 +60,7 @@ public class SyncToCentralCommand implements Command {
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
logger
.
debug
(
"Running 'sync to central' command"
);
List
<
String
>
nonOptionArgs
=
args
.
getNonOptionArgs
();
Assert
.
state
(!
nonOptionArgs
.
isEmpty
(),
"No command argument specified"
);
Assert
.
state
(
nonOptionArgs
.
size
()
==
3
,
"Release type or build info not specified"
);
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java
View file @
dbda2d0b
...
...
@@ -17,7 +17,8 @@
package
io
.
spring
.
concourse
.
releasescripts
.
sonatype
;
import
io.spring.concourse.releasescripts.ReleaseInfo
;
import
io.spring.concourse.releasescripts.system.ConsoleLogger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -35,12 +36,12 @@ import org.springframework.web.client.RestTemplate;
@Component
public
class
SonatypeService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SonatypeService
.
class
);
private
static
final
String
SONATYPE_REPOSITORY_URI
=
"https://oss.sonatype.org/service/local/repositories/releases/content/org/springframework/boot/spring-boot/"
;
private
final
RestTemplate
restTemplate
;
private
static
final
ConsoleLogger
console
=
new
ConsoleLogger
();
public
SonatypeService
(
RestTemplateBuilder
builder
,
SonatypeProperties
sonatypeProperties
)
{
String
username
=
sonatypeProperties
.
getUserToken
();
String
password
=
sonatypeProperties
.
getPasswordToken
();
...
...
@@ -61,7 +62,7 @@ public class SonatypeService {
.
getForEntity
(
String
.
format
(
SONATYPE_REPOSITORY_URI
+
"%s/spring-boot-%s.jar.sha1"
,
releaseInfo
.
getVersion
(),
releaseInfo
.
getVersion
()),
Object
.
class
);
if
(
HttpStatus
.
OK
.
equals
(
entity
.
getStatusCode
()))
{
console
.
log
(
"Already published to Sonatype."
);
logger
.
info
(
"Already published to Sonatype."
);
return
true
;
}
}
...
...
ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/system/ConsoleLogger.java
deleted
100644 → 0
View file @
ce011ca3
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
io
.
spring
.
concourse
.
releasescripts
.
system
;
import
org.slf4j.helpers.MessageFormatter
;
/**
* Simple console logger used to output progress messages.
*
* @author Madhura Bhave
*/
public
class
ConsoleLogger
{
public
void
log
(
String
message
,
Object
...
args
)
{
System
.
err
.
println
(
MessageFormatter
.
arrayFormat
(
message
,
args
).
getMessage
());
}
}
ci/images/releasescripts/src/main/resources/application.properties
View file @
dbda2d0b
spring.main.banner-mode
=
off
#
logging.level.io.spring.concourse
=
DEBUG
\ No newline at end of file
ci/images/releasescripts/src/test/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryServiceTests.java
View file @
dbda2d0b
...
...
@@ -133,7 +133,8 @@ class ArtifactoryServiceTests {
@SuppressWarnings
(
"unchecked"
)
void
distributeWhenSuccessful
()
throws
Exception
{
ReleaseInfo
releaseInfo
=
getReleaseInfo
();
given
(
this
.
bintrayService
.
isDistributionComplete
(
eq
(
releaseInfo
),
(
Set
<
String
>)
any
(),
any
())).
willReturn
(
true
);
given
(
this
.
bintrayService
.
isDistributionComplete
(
eq
(
releaseInfo
),
(
Set
<
String
>)
any
(),
any
())).
willReturn
(
false
,
true
);
this
.
server
.
expect
(
requestTo
(
"https://repo.spring.io/api/build/distribute/example-build/example-build-1"
))
.
andExpect
(
method
(
HttpMethod
.
POST
))
.
andExpect
(
content
().
json
(
...
...
ci/scripts/promote.sh
View file @
dbda2d0b
...
...
@@ -5,11 +5,11 @@ source $(dirname $0)/common.sh
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
java
-jar
/spring-boot-release-scripts.jar promote
$RELEASE_TYPE
$BUILD_INFO_LOCATION
>
/dev/null
||
{
exit
1
;
}
java
-jar
/spring-boot-release-scripts.jar promote
$RELEASE_TYPE
$BUILD_INFO_LOCATION
||
{
exit
1
;
}
java
-jar
/spring-boot-release-scripts.jar distribute
$RELEASE_TYPE
$BUILD_INFO_LOCATION
>
/dev/null
||
{
exit
1
;
}
java
-jar
/spring-boot-release-scripts.jar distribute
$RELEASE_TYPE
$BUILD_INFO_LOCATION
||
{
exit
1
;
}
java
-jar
/spring-boot-release-scripts.jar publishGradlePlugin
$RELEASE_TYPE
$BUILD_INFO_LOCATION
>
/dev/null
||
{
exit
1
;
}
java
-jar
/spring-boot-release-scripts.jar publishGradlePlugin
$RELEASE_TYPE
$BUILD_INFO_LOCATION
||
{
exit
1
;
}
echo
"Promotion complete"
echo
$version
>
version/version
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