-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task: reusables scripts pipeline agnostic (#24)
* feat: reusable script upload test assets * feat: update for folder or single * docs: update readme
- Loading branch information
1 parent
f05e61e
commit c99243f
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Scripts: CI/CD Pipelines for Test | ||
|
||
## Scripts | ||
|
||
### [upload-azstorage-blob.sh](./upload-azstorage-blob.sh) | ||
|
||
Input: Azure Blob Storage Destination and authentication | ||
Output: Uploads 1 or more files (or whole folder) of assets to Blob. | ||
|
||
#### Example 1: Upload a folder or directory | ||
|
||
`> ./upload-azstorage-blob.sh amido-stacks-rg-uks-dev amidostacksuksdev testresults /Users/estherlloyd/Documents/Github/stacks/stacks-webapp-template/packages/scaffolding-cli/templates/test/cypress-typescript-coreui/results/` | ||
|
||
#### Example 2: Upload a specific file(s) using patterns | ||
|
||
The pattern used for globbing files or blobs in the source. The supported patterns are '*', '?', '[seq]', and '[!seq]'. For more information, please refer to [fnmatch docs](https://docs.python.org/3.7/library/fnmatch.html). | ||
|
||
`> ./upload-azstorage-blob.sh amido-stacks-rg-uks-dev amidostacksuksdev testresults /Users/estherlloyd/Documents/Github/stacks/stacks-webapp-template/packages/scaffolding-cli/templates/test/cypress-typescript-coreui/results/ *report.html` | ||
|
||
## FAQ | ||
|
||
Q: Why is `Please run 'az login' to setup account.` occurring? | ||
A: If you haven't authenticated, then you need to login in to be able to resolve the Account Key. Please run `az login` or authenticate using an alternative method. See [azure-cli sign-in](https://docs.microsoft.com/en-gb/cli/azure/get-started-with-azure-cli?view=azure-cli-latest#sign-in) for more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Pipeline independent script that can be used for uploading test results to `Blob Storage` | ||
|
||
resource_group_name="$1" | ||
azure_storage_account="$2" | ||
azure_storage_container="$3" | ||
local_source_path="$4" | ||
local_source_file_pattern="${5:-**/*.*}" | ||
|
||
echo "Azure Details:" | ||
echo "Resource group name = $resource_group_name" | ||
|
||
echo "-----" | ||
echo "Upload Details:" | ||
echo "Storage Account Name = $azure_storage_account" | ||
echo "Container Name = $azure_storage_container" | ||
echo "Source Filepath = $local_source_path" | ||
echo "Source Filepattern = $local_source_file_pattern" | ||
|
||
echo "=======" | ||
|
||
echo "Retrieving Storage Account Key" | ||
export ACCOUNT_KEY=$(az storage account keys list -g $resource_group_name -n $azure_storage_account --query '[1].value') | ||
|
||
echo "Uploading Artefact" | ||
az storage blob upload-batch --account-name $azure_storage_account --account-key $ACCOUNT_KEY -d $azure_storage_container -s $local_source_path --pattern $local_source_file_pattern | ||
|
||
echo "Done" |