public static List < DockerImage > getDockerImagesFromAgents ( final int buildInfoId , TaskListener listener ) throws IOException , InterruptedException { List < DockerImage > dockerImages = new ArrayList < DockerImage > ( ) ; // Collect images from the master: dockerImages . addAll ( getAndDiscardImagesByBuildId ( buildInfoId ) ) ; // Collect images from all the agents: List < Node > nodes = Jenkins . getInstance ( ) . getNodes ( ) ; for ( Node node : nodes ) { if ( node == null || node . getChannel ( ) == null ) { continue ; } try { List < DockerImage > partialDockerImages = node . getChannel ( ) . call ( new MasterToSlaveCallable < List < DockerImage > , IOException > ( ) { public List < DockerImage > call ( ) throws IOException { List < DockerImage > dockerImages = new ArrayList < DockerImage > ( ) ; dockerImages . addAll ( getAndDiscardImagesByBuildId ( buildInfoId ) ) ; return dockerImages ; } } ) ; dockerImages . addAll ( partialDockerImages ) ; } catch ( Exception e ) { listener . getLogger ( ) . println ( "Could not collect docker images from Jenkins node '" + node . getDisplayName ( ) + "' due to: " + e . getMessage ( ) ) ; } } return dockerImages ; }
Retrieves from all the Jenkins agents all the docker images which have been registered for a specific build - info ID Only images for which manifests have been captured are returned .