Skip to content

azureBlobUpload

Uploads a specified file or directory into a given Azure Blob Storage.

Description

Uploads a specified file or directory into a given Azure Blob Storage. In case a file is uploaded that is already contained in the storage, it will be overwritten with the latest version.

Usage

We recommend to define values of step parameters via .pipeline/config.yml file.
In this case, calling the step is essentially reduced to defining the step name.
Calling the step can be done either in an orchestrator specific way (e.g. via a Jenkins library step) or on the command line.

library('piper-lib-os')

azureBlobUpload script: this
piper azureBlobUpload

Prerequisites

  • Before you can access Azure Storage, you will need an Azure subscription. If you do not have a subscription, create an account.
  • This step currently only supports authentication via Shared Access Signature (SAS).
  • You can generate a SAS token from the Azure Portal under Create a service SAS.
  • The SAS token must allow the actions "Write" and "Create" for the specified Azure Blob Storage.

Set up the Azure Credentials

To make your Azure credentials available to the jenkins library, store them as Jenkins credentials of type "Secret Text". The "Secret Text" must be in JSON format and contain the "account_name", "container_name", as well as the "sas_token".

For Example:

{
  "account_name": "asdfg12345jhgfdwertz4et5",
  "container_name": "abcde-lkjhg-qwertzui-fghj-9876-1234-7594rbnsmncx-xyz",
  "sas_token": "sig=1234567890wertzuiopaYXCVBNMASDsdfghjkloi1234567890qwedf%1993-12-15opphehttpsqtgcshje1234-aqwe-1234-5678-t57894u875LH2%nv23"
}

If the JSON string contains additional information, this is not a problem. These are skipped.

About Files/Directories to Upload

With this step you can upload single files as well as whole directories into your Azure Storage. File formats do not matter and directory structures are preserved.

Note: File paths must be specified in UNIX format. So the used path separator must be "/".

Parameters

Overview - Step

Name Mandatory Additional information
filePath yes
jsonCredentialsAzure (yes) Vault Secret pass via ENV, Vault or Jenkins credentials (azureCredentialsId)
script (yes) Jenkins only reference to Jenkins main pipeline script
verbose no activates debug output

Overview - Execution Environment

Orchestrator-specific only

These parameters are relevant for orchestrator usage and not considered when using the command line option.

Name Mandatory Additional information

Details

filePath

Name/Path of the file which should be uploaded

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_filePath (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: mtarFilePath

jsonCredentialsAzure

JSON String Credentials to access Azure Blob Storage

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_jsonCredentialsAzure (if set)
Secret yes
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☐ steps
  • ☐ stages
Resource references
Vault resource:
  name: azureDevOpsVaultSecretName
  default value: azure-dev-ops

Vault paths:
  • $(vaultPath)/azure-dev-ops
  • $(vaultBasePath)/$(vaultPipelineName)/azure-dev-ops
  • $(vaultBasePath)/GROUP-SECRETS/azure-dev-ops
Jenkins credential id:
  id: azureCredentialsId

script

Jenkins-specific: Used for proper environment setup.

The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, e.g. configuration parameters.

back to overview

Scope Details
Aliases -
Type Jenkins Script
Mandatory yes
Default
Secret no
Configuration scope
  • ☐ parameter
  • ☐ general
  • ☐ steps
  • ☐ stages
Resource references none

verbose

verbose output

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

azureCredentialsId

Jenkins-specific: Used for proper environment setup. See using credentials for details.

Jenkins 'Secret Text' credentials ID containing the JSON file to authenticate to the Azure Blob Storage

back to overview

Scope Details
Aliases -
Type string
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages

Example

azureBlobUpload(
    script: this,
    azureCredentialsId: "Azure_Credentials",
    filePath: "test.txt"
)