Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged PR 7124116: Support to collect build metrics #38

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .pipelines/post-build-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Post build steps to collect build logs
# Required packages: python3, azcopy

parameters:
- name: 'storageUrlPrefix'
type: string
default: 'https://sonicazurepipelines.blob.core.windows.net/buildinternal'
- name: 'sasKey'
type: string
default: $(sonicazurepipelines-SasToken)

steps:
- script: |
timestamp=$(date '+%Y%m%d-%H%M%S-%N')
relative_path="${timestamp:0:4}/${timestamp:4:2}/${timestamp:6:2}"
timelinefile="buildtimelines_$timestamp.json"
buildlogfile="buildlogs_$timestamp.json"
curl -s -o collect-build-logs.py 'https://raw.githubusercontent.com/sonic-net/sonic-pipelines/main/azure-pipelines/scripts/collect-build-logs.py'
chmod a+x collect-build-logs.py
build_url="$(System.TeamFoundationCollectionUri)DefaultCollection/$(System.TeamProjectId)/_apis/build/builds/$(Build.BuildId)"
./collect-build-logs.py "$build_url" "$(System.AccessToken)" "$timelinefile" "$buildlogfile"
ls -lt "$timelinefile" "$buildlogfile" 2>/dev/null
if [ -f $timelinefile ]; then
azcopy cp $timelinefile $PUBLISH_URL_PREFIX/buildtimelines/$relative_path/$timelinefile$SASKEY
fi

if [ ! -f $buildlogfile ]; then
azcopy cp $timelinefile $PUBLISH_URL_PREFIX/buildlogs/$relative_path/$buildlogfile$SASKEY
fi

exit 0
env:
PUBLISH_URL_PREFIX: ${{ parameters.storageUrlPrefix }}
SASKEY: ${{ parameters.sasKey }}
condition: always()
continueOnError: true
displayName: "Collect build logs"