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

Collect unsafe logs #679

Merged
merged 2 commits into from
Feb 2, 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
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)
}