My question is quite simple, I'm trying to learn AzureDevOps. I have a pipeline. In this pipeline I have a task with a bash script. This task basically adds files to the archive. This archive format:
I want it to be MyPackage_09192022_MyDeploymentComment.zip
For this, I created a variable called DeploymentComment in the pipeline. When I start a queque from this pipeline, I fill in the DeploymentComment field. I added this bash script to the task as filepath, so it gives the address of the file on the machine. I also gave the $DeploymentComment variable to the arguments in this task.
My script is as follows
date="$(date "%d%m%Y")"
zipName="MyPackage_"$date"_"$1
zip -r $zipname /home/admins/myDir/*
I am waiting for the content of the $DeploymentComment variable that I gave as an argument on the Pipeline to come to the part I specified as $1 in the script. In other words, when I start the queque, when I type my1stTry in the $DeploymentComment section, I expect the zip file created when I type my1stTry
I expect it to be MyPackage_09192022_my1stTry.zip but bash does not see this variable.
I can create a zip file as MyPackage_09192022_.zip.
What am I missing, can you help me?
CodePudding user response:
This will achieve your requirements:
trigger:
- none
pool:
vmImage: ubuntu-latest
variables:
- name: DeploymentComment #Define the variable
value: MyDeploymentComment
steps:
- bash: |
xxx="$(DeploymentComment)" #Use the pipeline variable
date="$(date "%d%m%Y")"
zipName="$(System.DefaultWorkingDirectory)/MyPackage_"$date"_"$xxx
echo $zipName
zip -r $zipName.zip ./*
ls
Successfully get the value on my side: