File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/main/groovy/com/avast/gradle/dockercompose/tasks Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -214,10 +214,18 @@ abstract class ComposeUp extends DefaultTask {
214214 String processesAsString = composeExecutor. get(). execute(' ps' , ' --format' , ' json' )
215215 String processesState = processesAsString
216216 try {
217- // Status field contains something like "Up 8 seconds", so we have to strip the duration.
218- Object [] processes = new JsonSlurper (). parseText(processesAsString)
217+ // Since Docker Compose 2.21.0, the output is not one JSON array but newline-separated JSONs.
218+ Map<String , Object > [] processes
219+ if (processesAsString. startsWith(' [' )) {
220+ processes = new JsonSlurper (). parseText(processesAsString)
221+ } else {
222+ processes = processesAsString. split(' \\ R' ). collect { new JsonSlurper (). parseText(it) }
223+ }
219224 List<Object > transformed = processes. collect {
220- if (it.Status . startsWith(' Up ' )) it.Status = ' Up'
225+ // Status field contains something like "Up 8 seconds", so we have to strip the duration.
226+ if (it. containsKey(' Status' ) && it.Status . startsWith(' Up ' )) it.Status = ' Up'
227+ it. remove(' RunningFor' ) // It also contains a duration information.
228+ it. remove(' Labels' ) // The order of labels is not stable.
221229 it
222230 }
223231 processesState = transformed. join(' \t ' )
You can’t perform that action at this time.
0 commit comments