Rewriting YAML file configuration during runtime in build pipeline using Powershell - azure

I have a task where in I need update the configuration in the YAML file's during build pipeline. I noticed that there is a task which does this, but cant be added in the organization and also I need to update the configuration for at-least 10 yaml files.
https://marketplace.visualstudio.com/items?itemName=jakkaj.vsts-yaml-writer&targetId=7e7d63c7-ba47-433d-affd-94b30e159ada
Can anyone guide me on this on how to achieve this ?

Here are two alternative methods:
Use the Command Line task to run git command to update your yaml files.
Use the Manual Validation task to pause the run and pop up an option box with "Resume" and "Reject", then you will recieve a notification(optional). You can update your YAML files during this time. When your work is done, click the button to resume the run.

Related

Issue with build pipeline

I am trying to implement a CI/CD pipeline as mentioned in this video by "tech with nana".
But I always end up with this error which says -make: command not found.
However, I have written in my pipeline code as explained by her in the video.
How do I fix this?
Check first if your YAML is correctly written.
Typically, -make should be - make (note the space between - and make).
The GitLab pipeline editor can help verify the configuration syntax automatically.

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.

Is it possible to either loop running tasks in agent at build or release pipelines?

Is it possible to loop running tasks in agent at build or release pipelines?
like for-each from json file we have list of blocks in json file
for-each block i will start the running the task of the agent again
It's not able to use for-each control to run tasks multiple times in your pipeline.
If you just want to run the tasks multiple times, you could simply add the task multiple times when using Classic UI pipeline or using template when using YAML pipeline.
For how to use template, kindly refer answer in this question: Azure Devops YAML pipeline - how to repeat a task.
If you just want to use the loop to re-run/re-try failed task/step. This is also not supported at the moment.
There has been a related user voice.
Rerun failed build task/step
https://developercommunity.visualstudio.com/idea/365697/rerun-failed-build-taskstep.html
Multiple persons commented and echoed. You could monitor the status of above user voice.

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.

Convert visual build pipeline in yaml file

I'm working with Azure DevOps pipeline and I'm using the visual designer.
But there is also the YAML file. I would like to export my Build pipeline into a YAML file. It seems to be possible like mentionned in this Github issue (https://github.com/MicrosoftDocs/vsts-docs/issues/2504) using the View YAML button.
But this button is disable in my project (I cannot click on it):
I don't know how to enable it. The preview feature New YAML pipeline creation experience is enabled. I'm using some Task that are tagged as Preview. Can it be a reason?
Does someone know why it is disabled and how to enabled it?
I also have the same problem for several projects on pipeline level:
Try to check the agent level. It may be available:
FYI you will shortly be able to export the entire pipeline to YAML (the ability to export individual tasks will be removed);
https://devblogs.microsoft.com/devops/replacing-view-yaml/

Resources