File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Post build steps to collect build logs
2+ # Required packages: python3, azcopy
3+
4+ parameters :
5+ - name : ' storageUrlPrefix'
6+ type : string
7+ default : ' https://sonicazurepipelines.blob.core.windows.net/buildinternal'
8+ - name : ' sasKey'
9+ type : string
10+ default : $(sonicazurepipelines-SasToken)
11+
12+ steps :
13+ - script : |
14+ timestamp=$(date '+%Y%m%d-%H%M%S-%N')
15+ relative_path="${timestamp:0:4}/${timestamp:4:2}/${timestamp:6:2}"
16+ timelinefile="buildtimelines_$timestamp.json"
17+ buildlogfile="buildlogs_$timestamp.json"
18+ curl -s -o collect-build-logs.py 'https://raw.githubusercontent.com/sonic-net/sonic-pipelines/main/azure-pipelines/scripts/collect-build-logs.py'
19+ chmod a+x collect-build-logs.py
20+ build_url="$(System.TeamFoundationCollectionUri)DefaultCollection/$(System.TeamProjectId)/_apis/build/builds/$(Build.BuildId)"
21+ ./collect-build-logs.py "$build_url" "$(System.AccessToken)" "$timelinefile" "$buildlogfile"
22+ ls -lt "$timelinefile" "$buildlogfile" 2>/dev/null
23+ if [ -f $timelinefile ]; then
24+ azcopy cp $timelinefile $PUBLISH_URL_PREFIX/buildtimelines/$relative_path/$timelinefile$SASKEY
25+ fi
26+
27+ if [ ! -f $buildlogfile ]; then
28+ azcopy cp $timelinefile $PUBLISH_URL_PREFIX/buildlogs/$relative_path/$buildlogfile$SASKEY
29+ fi
30+
31+ exit 0
32+ env :
33+ PUBLISH_URL_PREFIX : ${{ parameters.storageUrlPrefix }}
34+ SASKEY : ${{ parameters.sasKey }}
35+ condition : always()
36+ continueOnError : true
37+ displayName : " Collect build logs"
You can’t perform that action at this time.
0 commit comments