Commit 60de21f8 authored by Dennis Appelt's avatar Dennis Appelt Committed by Rémy Coutable

Make report name unique

parent 011f0a42
...@@ -19,15 +19,22 @@ function getMD5HashFromFile(data) { ...@@ -19,15 +19,22 @@ function getMD5HashFromFile(data) {
try { try {
const file = 'gl-dependency-scanning-report.json' const file = 'gl-dependency-scanning-report.json'
const data = fs.readFileSync(file) const data = fs.readFileSync(file)
const [filename, fileext] = path.basename(file).split('.')
const uniqueId = process.env['CI_PIPELINE_ID'] && process.env['CI_JOB_ID'] ?
process.env['CI_PIPELINE_ID'] + '-' + process.env['CI_JOB_ID'] :
Date.now()
const key = path.join('package_hunter_test', filename + '-' + uniqueId + '.' + fileext)
const responseData = await s3Client.send( const responseData = await s3Client.send(
new PutObjectCommand({ new PutObjectCommand({
Bucket: 'gl-logs-for-panther-test', Bucket: 'gl-logs-for-panther-test',
Key: path.join('package_hunter_test', path.basename(file)), Key: key,
Body: data, Body: data,
ContentMD5: getMD5HashFromFile(data), ContentMD5: getMD5HashFromFile(data),
}), }),
) )
console.log('Successfully uploaded %s', file) console.log('Successfully uploaded %s to %s', file, key)
} catch (err) { } catch (err) {
if (err.name === 'CredentialsProviderError' || err.name === 'AuthorizationHeaderMalformed') if (err.name === 'CredentialsProviderError' || err.name === 'AuthorizationHeaderMalformed')
console.log('Could not upload the report. Are AWS credentials configured in ~/.aws/credentials?') console.log('Could not upload the report. Are AWS credentials configured in ~/.aws/credentials?')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment