split debug logs for sendSlack() length limit
refs DE-431 [build-registry-path=jenkins/canvas-lms/de-431-try-2] [change-merged] Change-Id: I4f7eead3f696535f29603291a5f4e2a863904026 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/255503 Reviewed-by: Kyle Rosenbaum <krosenbaum@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Aaron Ogata <aogata@instructure.com> Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
parent
8b4661a0ff
commit
34c6147bf4
|
@ -194,17 +194,44 @@ def slackSendCacheBuild(block) {
|
|||
|
||||
def buildEndTime = System.currentTimeMillis()
|
||||
|
||||
def buildLog = sh(script: 'cat tmp/docker-build-short.log', returnStdout: true).trim()
|
||||
def buildLog = sh(script: 'cat tmp/docker-build.log', returnStdout: true).trim()
|
||||
def buildLogParts = buildLog.split('\n')
|
||||
def buildLogPartsLength = buildLogParts.size()
|
||||
|
||||
slackSend(
|
||||
channel: '#jenkins_cache_noisy',
|
||||
message: """<${env.GERRIT_CHANGE_URL}|#${env.GERRIT_CHANGE_NUMBER}> on ${env.GERRIT_PROJECT}. Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}>
|
||||
// slackSend() has a ridiculously low limit of 2k, so we need to split longer logs
|
||||
// into parts.
|
||||
def i = 0
|
||||
def partitions = []
|
||||
def cur_partition = []
|
||||
def max_entries = 5
|
||||
|
||||
while(i < buildLogPartsLength) {
|
||||
cur_partition.add(buildLogParts[i])
|
||||
|
||||
if(cur_partition.size() >= max_entries) {
|
||||
partitions.add(cur_partition)
|
||||
|
||||
cur_partition = []
|
||||
}
|
||||
|
||||
i++
|
||||
}
|
||||
|
||||
if(cur_partition.size() > 0) {
|
||||
partitions.add(cur_partition)
|
||||
}
|
||||
|
||||
for(i = 0; i < partitions.size(); i++) {
|
||||
slackSend(
|
||||
channel: '#jenkins_cache_noisy',
|
||||
message: """<${env.GERRIT_CHANGE_URL}|#${env.GERRIT_CHANGE_NUMBER}> on ${env.GERRIT_PROJECT}. Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> (${i} / ${partitions.size() - 1})
|
||||
Duration: ${buildEndTime - buildStartTime}ms
|
||||
Instance: ${env.NODE_NAME}
|
||||
|
||||
```${buildLog}```
|
||||
"""
|
||||
)
|
||||
```${partitions[i].join('\n\n')}```
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// These functions are intentionally pinned to GERRIT_EVENT_TYPE == 'change-merged' to ensure that real post-merge
|
||||
|
|
|
@ -4,10 +4,10 @@ set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
|||
|
||||
export CACHE_VERSION="2020-12-15.1"
|
||||
|
||||
echo "" > tmp/docker-build-short.log
|
||||
echo "" > tmp/docker-build.log
|
||||
|
||||
function add_log {
|
||||
echo -e "$1\n" >> tmp/docker-build-short.log
|
||||
echo "$1" >> tmp/docker-build.log
|
||||
}
|
||||
|
||||
function compute_tags {
|
||||
|
@ -41,7 +41,7 @@ function tag_many {
|
|||
local dstTags=$@
|
||||
|
||||
for imageTag in $dstTags; do
|
||||
[ "$srcTag" != "$imageTag" ] && [[ "$imageTag" != "local/"* ]] && add_log "alias\n from $srcTag\n to $imageTag"
|
||||
[ "$srcTag" != "$imageTag" ] && [[ "$imageTag" != "local/"* ]] && add_log "alias $imageTag"
|
||||
|
||||
docker tag $srcTag $imageTag
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue