https://github.com/clarenceb/securefile-upload
Azure DevOps SecureFile upload from CLI example
https://github.com/clarenceb/securefile-upload
azuredevops cli example typescript
Last synced: 3 days ago
JSON representation
Azure DevOps SecureFile upload from CLI example
- Host: GitHub
- URL: https://github.com/clarenceb/securefile-upload
- Owner: clarenceb
- License: mit
- Created: 2020-05-20T01:31:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-27T14:05:12.000Z (almost 3 years ago)
- Last Synced: 2024-12-30T08:40:53.936Z (about 1 year ago)
- Topics: azuredevops, cli, example, typescript
- Language: TypeScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
How to upload SecureFile to Azure Pipelines from CLI
====================================================
This is just a demo with no error handling for is illustrative purposes only.
Prequisities
------------
* Node and NPM installed
* Bash shell
* Create an Azure DevOps Organization
* Create an Azure DevOps Project
* Create a PAT for your Azure DevOps user with appropriate access
Usage with Bash shell
---------------------
```sh
npm install -g typescript
npm install
TOKEN=""
ORG="https://dev.azure.com/"
PROJECT=""
tsc uploadSecureFile.ts
# Create a demo file to upload (or use a real file you want to upload)
ls -1 > demofile.txt
zip demofile.zip demofile.txt
# Upload secret file with same basename (demofile.zip)
node uploadSecureFile.js ./demofile.zip
# Upload secret file with custom name (something.zip)
node uploadSecureFile.js ./demofile.zip something.zip
```
Your secure file will be in under **Pipelines** / **Library** / **Secure files** for your project.
Testing the secret file
-----------------------
In Azure Pipelines you can use the [Download Secure File Task](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-secure-file) to retrieve the secret.
e.g. in YAML
```yaml
- task: DownloadSecureFile@1
name: mysecret
displayName: 'Download My Secret'
inputs:
secureFile: 'something.zip'
- script: |
echo Do somethign usefule with the secret...
ls -lah $(mysecret.secureFilePath)
file $(mysecret.secureFilePath)
unzip -t $(mysecret.secureFilePath)
```
You can also use Classic Build/Release Tasks to download secret files.