@@ -228,27 +228,40 @@ def send_metrics_annotations(annotationData, workspace, repo_slug, commit_hash,
228228
229229def saveDataForSending (summary , annotationData , link , verbose ):
230230
231- with open ("metrics_summary.bb_txt" , "wb" ) as fd :
231+ savePath = os .path .join (os .environ ['BITBUCKET_CLONE_DIR' ],"saved-metrics-data" )
232+
233+ if not os .path .exists (savePath ):
234+ os .makedirs (savePath )
235+
236+ fname = os .path .join (savePath ,"metrics_summary.bb_txt" )
237+ with open (fname , "wb" ) as fd :
232238 fd .write (summary .encode (encFmt ,'replace' ))
233239
234- with open ("metrics_annotation_data.bb_txt" , "wb" ) as fd :
240+ fname = os .path .join (savePath ,"metrics_annotation_data.bb_txt" )
241+ with open (fname , "wb" ) as fd :
235242 saveData = json .dumps (annotationData , ensure_ascii = False ).encode (encFmt , "replace" )
236243 fd .write (saveData )
237244
238- with open ("metrics_link.bb_txt" , "wb" ) as fd :
245+ fname = os .path .join (savePath ,"metrics_link.bb_txt" )
246+ with open (fname , "wb" ) as fd :
239247 fd .write (link .encode (encFmt ,'replace' ))
240248
241249def readSavedData (verbose = False ):
242250
243- with open ("metrics_summary.bb_txt" , "rb" ) as fd :
251+ savePath = os .path .join (os .environ ['BITBUCKET_CLONE_DIR' ],"saved-metrics-data" )
252+
253+ fname = os .path .join (savePath ,"metrics_summary.bb_txt" )
254+ with open (fname , "rb" ) as fd :
244255 summary = fd .read ().decode (encFmt , 'replace' )
245256
246- with open ("metrics_annotation_data.bb_txt" , "rb" ) as fd :
257+ fname = os .path .join (savePath ,"metrics_annotation_data.bb_txt" )
258+ with open (fname , "rb" ) as fd :
247259 raw = fd .read ()
248260 rawAsText = raw .decode (encFmt , "replace" )
249261 annotationData = json .loads (rawAsText )
250262
251- with open ("metrics_link.bb_txt" , "rb" ) as fd :
263+ fname = os .path .join (savePath ,"metrics_link.bb_txt" )
264+ with open (fname , "rb" ) as fd :
252265 link = fd .read ().decode (encFmt , 'replace' )
253266
254267 return summary , annotationData , link
0 commit comments