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
a215103b
Commit
a215103b
authored
Jun 03, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.4.x' into 1.5.x
parents
5722c149
31ff7f18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
1 deletion
+52
-1
SysVinitLaunchScriptIT.java
...ngframework/boot/launchscript/SysVinitLaunchScriptIT.java
+52
-1
No files found.
spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java
View file @
a215103b
...
...
@@ -22,6 +22,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Pattern
;
...
...
@@ -32,7 +33,9 @@ import javax.ws.rs.client.Entity;
import
javax.ws.rs.client.WebTarget
;
import
com.github.dockerjava.api.DockerClient
;
import
com.github.dockerjava.api.DockerClientException
;
import
com.github.dockerjava.api.command.DockerCmd
;
import
com.github.dockerjava.api.model.BuildResponseItem
;
import
com.github.dockerjava.api.model.Frame
;
import
com.github.dockerjava.core.CompressArchiveUtil
;
import
com.github.dockerjava.core.DockerClientBuilder
;
...
...
@@ -265,10 +268,58 @@ public class SysVinitLaunchScriptIT {
}
private
String
buildImage
(
DockerClient
docker
)
{
BuildImageResultCallback
resultCallback
=
new
BuildImageResultCallback
();
String
dockerfile
=
"src/test/resources/conf/"
+
this
.
os
+
"/"
+
this
.
version
+
"/Dockerfile"
;
String
tag
=
"spring-boot-it/"
+
this
.
os
.
toLowerCase
()
+
":"
+
this
.
version
;
BuildImageResultCallback
resultCallback
=
new
BuildImageResultCallback
()
{
private
List
<
BuildResponseItem
>
items
=
new
ArrayList
<
BuildResponseItem
>();
@Override
public
void
onNext
(
BuildResponseItem
item
)
{
super
.
onNext
(
item
);
this
.
items
.
add
(
item
);
}
@Override
public
String
awaitImageId
()
{
try
{
awaitCompletion
();
}
catch
(
InterruptedException
ex
)
{
throw
new
DockerClientException
(
"Interrupted while waiting for image id"
,
ex
);
}
return
getImageId
();
}
@SuppressWarnings
(
"deprecation"
)
private
String
getImageId
()
{
if
(
this
.
items
.
isEmpty
())
{
throw
new
DockerClientException
(
"Could not build image"
);
}
String
imageId
=
extractImageId
();
if
(
imageId
==
null
)
{
throw
new
DockerClientException
(
"Could not build image: "
+
this
.
items
.
get
(
this
.
items
.
size
()
-
1
).
getError
());
}
return
imageId
;
}
private
String
extractImageId
()
{
Collections
.
reverse
(
this
.
items
);
for
(
BuildResponseItem
item
:
this
.
items
)
{
if
(
item
.
isErrorIndicated
()
||
item
.
getStream
()
==
null
)
{
return
null
;
}
if
(
item
.
getStream
().
contains
(
"Successfully built"
))
{
return
item
.
getStream
().
replace
(
"Successfully built"
,
""
).
trim
();
}
}
return
null
;
}
};
docker
.
buildImageCmd
(
new
File
(
dockerfile
)).
withTag
(
tag
).
exec
(
resultCallback
);
String
imageId
=
resultCallback
.
awaitImageId
();
return
imageId
;
...
...
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