66from collections .abc import Iterable
77
88import requests
9+ import yaml
910
1011import artbotlib .exectools
1112from artbotlib import util , pipeline_image_util
@@ -236,6 +237,19 @@ def get_builds_from_db(self, commit, task_state):
236237
237238 return response .json ()
238239
240+ def is_image_for_release (self , image_name ):
241+ """
242+ Exclude images that are not in payloads
243+ """
244+ url = f'https://raw.githubusercontent.com/openshift-eng/ocp-build-data/openshift-{ self .version } /images/{ image_name } .yml'
245+ response = requests .get (url )
246+ if response .status_code == 200 :
247+ yaml_content = yaml .safe_load (response .text )
248+ # Check key value for for_relaese
249+ return yaml_content .get ('for_release' , True )
250+ else :
251+ self .logger .info (f'response.status_code = { response .status_code } ' )
252+
239253 def build_from_commit (self , task_state ):
240254 """
241255 Function to get all the build ids associated with a list of commits
@@ -249,8 +263,9 @@ def build_from_commit(self, task_state):
249263 self .logger .info ('Found %s builds from commit %s' , count , commit )
250264 builds = response_data ["results" ]
251265 build_for_image = {}
252- for image_name , build_id in [(b ["build_0_name" ], int (b ["build_0_id" ])) for b in builds ]:
253- if image_name not in build_for_image or build_id < build_for_image [image_name ]:
266+ for image_name , build_id , dg_name in [(b ["build_0_name" ], int (b ["build_0_id" ]), b ["dg_name" ]) for b in builds ]:
267+ # checks which image to exclude from payload
268+ if self .is_image_for_release (dg_name ) and (image_name not in build_for_image or build_id < build_for_image .get (image_name , float ('inf' ))):
254269 build_for_image [image_name ] = build_id
255270 return build_for_image .values ()
256271 self .logger .info ('Found no builds from commit %s' , commit )
@@ -263,6 +278,7 @@ def find_builds(self):
263278
264279 successful_builds = self .build_from_commit (BREW_TASK_STATES ["Success" ])
265280 if successful_builds :
281+ self .logger .info (f'*** successful_builds: { successful_builds } ***' )
266282 self .logger .info ("Found successful builds for given PR" )
267283 nvr = None
268284 for build in successful_builds :
0 commit comments