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

cleanup: remove blob storage upload from publishReports #860

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
8 changes: 2 additions & 6 deletions test/groovy/PublishReportsStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ class PublishReportsStepTests extends BaseTest {
// when running with a html filename
script.call([file])
printCallStack()
// then timeout is default and filename manipulations is in place
assertTrue(assertMethodCallContainsPattern('withEnv', 'TIMEOUT=60'))
// then filename manipulations is in place
assertTrue(assertMethodCallContainsPattern('withEnv', "FILENAME=${file}"))
assertTrue(assertMethodCallContainsPattern('withEnv', 'UPLOADFLAGS=--content-type="text/html"'))
assertTrue(assertMethodCallContainsPattern('sh', 'az storage blob upload --account-name=prodjenkinsreports --container=reports --timeout=${TIMEOUT} --file=${FILENAME} --name=${FILENAME} ${UPLOADFLAGS} --overwrite'))
// another filename manipulations is in place
assertTrue(assertMethodCallContainsPattern('withEnv', 'SOURCE_DIRNAME=.'))
assertTrue(assertMethodCallContainsPattern('withEnv', 'DESTINATION_PATH=/'))
Expand All @@ -72,11 +70,9 @@ class PublishReportsStepTests extends BaseTest {
def file = '/bar/foo.css'
script.call([file])
printCallStack()
// then timeout is default and filename manipulations is in place
assertTrue(assertMethodCallContainsPattern('withEnv', 'TIMEOUT=60'))
// then filename manipulations is in place
assertTrue(assertMethodCallContainsPattern('withEnv', "FILENAME=${file}"))
assertTrue(assertMethodCallContainsPattern('withEnv', 'UPLOADFLAGS=--content-type="text/css"'))
assertTrue(assertMethodCallContainsPattern('sh', 'az storage blob upload --account-name=prodjenkinsreports --container=reports --timeout=${TIMEOUT} --file=${FILENAME} --name=${FILENAME} ${UPLOADFLAGS} --overwrite'))
// another filename manipulations is in place
assertTrue(assertMethodCallContainsPattern('withEnv', 'SOURCE_DIRNAME=/bar'))
assertTrue(assertMethodCallContainsPattern('withEnv', 'DESTINATION_PATH=/bar'))
Expand Down
6 changes: 0 additions & 6 deletions vars/publishReports.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* See https://issues.jenkins-ci.org/browse/INFRA-947 for more
*/
def call(List<String> files, Map params = [:]) {
def timeout = params.get('timeout') ?: '60'

if (!infra.isTrusted() && !infra.isInfra()) {
error 'Can only call publishReports from within the trusted.ci environment'
}
Expand Down Expand Up @@ -45,16 +43,12 @@ def call(List<String> files, Map params = [:]) {
def dirname = Arrays.copyOfRange(directory, 0, directory.size()-1 ).join("/")

withEnv([
"TIMEOUT=${timeout}",
"FILENAME=${filename}",
"UPLOADFLAGS=${uploadFlags}",
"SOURCE_DIRNAME=${dirname ?: '.'}",
"DESTINATION_PATH=${dirname ?: '/'}",
"PATTERN=${ basename ?: '*' }",
]) {
// Blob container can be removed once files are uploaded on the azure file storage
sh 'az storage blob upload --account-name=prodjenkinsreports --container=reports --timeout=${TIMEOUT} --file=${FILENAME} --name=${FILENAME} ${UPLOADFLAGS} --overwrite'

// `az storage file upload` doesn't support file uploaded in a remote directory that doesn't exist but upload-batch yes. Unfortunately the cli syntax is a bit different and requires filename and directory name to be set differently.
sh 'az storage file upload-batch --account-name prodjenkinsreports --destination reports --source ${SOURCE_DIRNAME} --destination-path ${DESTINATION_PATH} --pattern ${PATTERN} ${UPLOADFLAGS}'
}
Expand Down