Skip to content

Commit

Permalink
Collect unsafe logs (#679)
Browse files Browse the repository at this point in the history
* Collect unsafe logs

* Fix: internal bucket
  • Loading branch information
mtojek authored Feb 2, 2022
1 parent e78b275 commit 0c62930
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pipeline {
KIND_VERSION = 'v0.11.1'
K8S_VERSION = 'v1.23.0'
JOB_GCS_BUCKET = 'beats-ci-temp'
JOB_GCS_BUCKET_INTERNAL = 'beats-ci-temp-internal'
JOB_GCS_CREDENTIALS = 'beats-ci-gcs-plugin'
JOB_GCS_EXT_CREDENTIALS = 'beats-ci-gcs-plugin-file-credentials'
JOB_SIGNING_CREDENTIALS = 'sign-artifacts-with-gpg-job'
Expand Down Expand Up @@ -113,7 +114,7 @@ pipeline {
'sign-with-elastic': generateTestSignWithElasticStage()
]

def checkSinglePackageTasks = generateTestCheckSinglePackageStage(artifacts: ['build/test-results/*.xml', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*'], junitArtifacts: true, publishCoverage: true)
def checkSinglePackageTasks = generateTestCheckSinglePackageStage()
def tasks = basicTasks + checkSinglePackageTasks
parallel tasks
}
Expand Down Expand Up @@ -190,9 +191,7 @@ def generateTestSignWithElasticStage() {
}

def generateTestCheckSinglePackageStage(Map args = [:]) {
def artifacts = args.get('artifacts') ? args.get('artifacts') : []
def junitArtifacts = args.get('junitArtifacts') ? args.get('junitArtifacts') : false
def publishCoverage = args.get('publishCoverage') ? args.get('publishCoverage') : false
def artifacts = ['build/test-results/*.xml', 'build/elastic-stack-dump/check-*/logs/*.log', 'build/elastic-stack-dump/check-*/logs/fleet-server-internal/*']

def integrations = [:]
dir("test/packages/parallel") {
Expand All @@ -216,16 +215,11 @@ def generateTestCheckSinglePackageStage(Map args = [:]) {
artifacts.each { artifact ->
archiveArtifacts(allowEmptyArchive: true, artifacts: "${artifact}")
}
archiveArtifactsSafe("insecure-logs/${it}", "build/elastic-stack-dump/check-${it}/logs/elastic-agent-internal/*")
archiveArtifactsSafe("insecure-logs/${it}/container-logs", "build/container-logs/*.log")

if (junitArtifacts) {
junit(allowEmptyResults: true,
keepLongStdio: true,
testResults: "build/test-results/*.xml")
}

if (publishCoverage) {
stashCoverageReport()
}
junit(allowEmptyResults: true, keepLongStdio: true, testResults: "build/test-results/*.xml")
stashCoverageReport()
}
}
}
Expand Down Expand Up @@ -338,4 +332,17 @@ def withCloudTestEnv(Closure body) {
withEnvMask(vars: maskedVars) {
body()
}
}

def archiveArtifactsSafe(remotePath, artifacts) {
r = sh(label: "areArtifactsPresent", script: "ls ${artifacts}", returnStatus: true)
if (r != 0) {
echo "areArtifactsPresent: artifacts files not found, nothing will be archived"
return
}

googleStorageUploadExt(
bucket: "gs://${JOB_GCS_BUCKET_INTERNAL}/${env.JOB_NAME}-${env.BUILD_ID}/${remotePath}",
credentialsId: "${JOB_GCS_EXT_CREDENTIALS}",
pattern: artifacts)
}

0 comments on commit 0c62930

Please sign in to comment.