Adding Date to Zip File in Azure DevOps Release Task - azure

I have created a Release in the Azure DevOps environment, and added the Archive File task to my stage. I want the name of the zip file to include the date the file was created on, but there doesn't seem to be syntax that allows me to do it. Does anyone know of a way to include the date in the file name?

Looks you could not use that directly in Archive file to create of the task, the workaround is to configure the Release name format with $(Date: yyyyMMdd) in the release pipeline -> Options like below.
Then in the task, reference it with $(Release.ReleaseName), e.g. xxxxxx/test-$(Release.ReleaseName).zip.
Run the task, it works on my side.

Related

Are changes made to files in azure pipeline discarded after pipeline runs?

Lets say one of the steps is replace content of one file with another file using CmdLine script task in yaml file. After pipeline runs do changes made to that file stick around or are they discarded?
If you are talking about hosted runners, the changes will be discarded. If the file is part of your repository, you can check it in within your pipeline to persist the changes.

Azure Pipeline - Zip deployment

I have just begun in Azure DevOps.
I made the CI/CD pipeline for our dot net project. CI successfully done and generated the artifact, but in CD getting failed always, configured deployment type = zip;
I am completely new for Azure, so anyone look at this issue earlier and sorted out. Pls share your experience.
Your array before red line says "There is not enough space on the disk". Please check your disk - probably storing or replacing the zip is not possible because of missing space.
From the steps on the screenshot you shared, I do not see any step to archive the artifact files as a ZIP file.
Before the deployment, you need to use the Archive Files task to archive all the required artifact files as a ZIP file. Then execute the deployment with this ZIP file.

How can I exclude a file on Azure Devops in the Deployment?

I apologize for my english, im using a translator.
I need make a deployment on Azure Devops using Continous Deployment but i need exclude a file from the repository (i cant change the repository) then create a deployment in IIS.
I have a WebService file in the repository but i cant ignore or delete it from git. I need to use Azure Devops to ignore it then make a continuous deployment.
Another approch is also to use .artifactsignore. By including this file you can describe which files you want to ignore before building the artifacts package. The tricky part here is correct placing of the file.
Where you save the .artifactignore file depends which path you have specified for the publish pipeline artifact task in your pipeline definition.
Here is good example which helped me to use it:
https://www.jfe.cloud/control-pipeline-artifacts-with-artifactignore-file/
You can use the task Delete Files, as covered below:
# Delete files
# Delete folders, or files matching a pattern
- task: DeleteFiles#1
inputs:
#SourceFolder: # Optional
#Contents: 'myFileShare'
#RemoveSourceFolder: # Optional
The input source folder can be folder $(rootFolder) or $(Build.ArtifactStagingDirectory).
I've had a similar problem and solved it this way. Especially .git or .vsfolder.

Use CSV in Azure DevOps Pipeline

We are trying to set up an infrastructure pipeline in Azure DevOps and we have a requirement to have several variables set with each infra build, which will be defined by the project. This also involves copying VMs from one location to another and renaming etc. I can do this through Powershell, however I'm struggling on how to import all the variables for each infra build. Since there are a few I was thinking I could use an Excel file (csv) and then do a foreach loop, that way the code is consistent and simpler.
Is there a way to have a CSV uploaded to Azure DevOps that triggers the powershell pipeline to run or is there even a way I can add a CSV to a pipeline, I can always look at another trigger once the CSV has been uploaded?
There are 7 fields (columns) in each infra build and there could be up to 30-50 builds (rows) running at each time hence the desire to automate it and use a CSV, adding variables each time is just not practical.
Thanks in advance and hope that makes snese
Thanks
Is there a way to have a CSV uploaded to Azure DevOps that triggers
the powershell pipeline to run or is there even a way I can add a CSV
to a pipeline, I can always look at another trigger once the CSV has
been uploaded?
From this doc, the * can only set as the final character.
So, you can create a folder named 'csv' to upload the '.csv' file, then set your yml file like this:
trigger:
branches:
include:
- main
paths:
include:
- 'csv/*'

Is there any way to do selective deployment in azure devops?

I have a release pipeline which i use to deploy my resources to other environments. All works fine but the problem is that every time i deploy, all the resources even if no modification is made, are deployed. Is there a way through which i can do selective deployment; i.e. I deploy only those resources which have been modified. Any help would do. Thanks.
That`s a broad question. There is no out-of-box feature to select units to deploy. But you can use variables in the release pipeline:
Define a variable for each resource/unit and set some default value and "Settable at release time" property.
For each resource, define a separate task to deploy and define the custom condition, like: and(succeeded(), eq(variables['Custom.DeployUnit1'], 'YES'))
You can update these variables at the release creation time:
Is there any way to do selective deployment in azure devops?
There is no such out of box way to selective deployment in azure devops.
That because Azure devops release does not support release only changed files since only release changed files not always meaningful and could not archive what the project intend to release (such as the config file only changed in a commit).
But you could create a PowerShell script to compare timestamp for all files:
Create XML file that stores the last upload/publish information of
each files (e.g. file name, date time, changeset/commit version).
Create a PowerShell script file that included the logical to compare
files (get files metadata and compare with that XML file) and copy
updated files to specific folder
Publish the files in that folder
Check the similar thread for some more details.
Besides, if deploying via the deploy.cmd or MSDeploy.exe, you could also use the the -useChecksum WebDeploy flag:
WebDeploy/MSDeploy Quick Tip: Only Deploy Changed Files
Hope this helps.

Resources