create local fileList from Azure Devops Repos - azure

I am working on a script solution to capture status changes of an Azure DevOps repo.
Basically here is what we need:
The script is supposed to create a file list that contains ALL files in an Azure repo, and save it to local drive.
If the newly generated file list has changes, i.e., a file gets removed/added, the script should create a separate file list that records these changes.
Step 2 I can take care of myself.
But since I am not familiar with the DevOps API, could anyone help me on this?
Thank you in advance

For the first question, you can fetch repo to local drive, and list files in this directory.
If you could fetch repo to local drive, you can git log -1 for latest change commit.

Related

How to set bin directory in azure pipelines?

I wrote two azure pipelines. One pipeline build my app as a tool and publishes to a artifact feed.
My second pipeline runs that app from artifact feed. Problem is that my app does not see appsettings.json. When I tried to print current directory I saw that is root repo folder. How to solve this?
What have I tried is to set workingDirectory in task that run's tool as:
$(Build.BinariesDirectory)
$(Agent.BuildDirectory)
etc..
So, when I run tool locally and print current directory files i get all DLL's included. But on azure I get repo root.
Is my approach good or completely wrong?

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 to upload an artifact to some folder inside a remote machine

I m completely new to github actions and not sure in which direction I should search for help so posting my problem here.
I have a vm running on azure. I have a github action which is generating an artifact on push, lets say myPackage.zip. I want to to extract it and paste into a folder C:/path/to/my/app/
I can access my vm using remote desktop as its windows based machine.
You can use this action: https://github.com/actions/upload-artifact
It allows uploading any file from any system into build artifacts.

How to download files from a specific git pull request?

I have a Pull Request on an azure devops remote git repository in format like this https://project-domain/project-name/_git/repo-name/pullrequest/xxxxx
Is there an easy way to just download the files which are part of this pull request without having to clone the entire repository?
If i have to use commit ids which are part of this pull request, that's alright with me. please let me know if anyone has done this before
In Azure DevOps, when viewing a Pull Request, on the Files tab, next to each file is a menu with three dots (...) with an option for "Download". You can do that for any file you wish to download.
However, it's very important to realize that the file you are downloading is the file from the point of view of the source branch. If the source branch is not up to date with the target branch, then you might not be downloading the final version of that file that will exist at the time the PR is completed. If you wish to download the future version of the file after PR is completed, then you should select the three dots (...) button next to the Complete button, and select "View Merge Commit". From there you can download each of the files the same way as previously described, and now you'll get the version of the files that would exist if you completed the PR right now. Obviously if that file gets modified on the target branch between now and when the PR is actually completed, the file would change yet again.
Side note, if you have many files in the PR that you wish to download, as far as I know you cannot download them all together in one shot from the UI, though you can probably automate it using the API (or by cloning and doing a diff which you said you wanted to avoid).

Azure DevOps - Clean up old releases on on-premise server?

I have a pipeline that deploys code to an IIS folder on an on-premise server. I'm trying to figure out how to best delete old release folders. I'm not seeing anything obvious within DevOps.
Is there a native way of doing this? Or should I roll my own PowerShell script to delete old releases?
Is there a native way of doing this?
Yes, of course there is.
Open your deploy task, go Advanced Deployment Options and then enable the option Remove Additional Files at Destination
Noted: This "delete" operation I mentioned is not mean that clear all the files in local IIS folder. It just delete the files at the destination where there's no corresponding file in the package which is being deployed.
In one word, for some files which same with previous, it will be override as the latest files. And, for any left over files from a previous deployment that are no longer required, they will be deleted.
If you do not trust this option and want to clear the previous files completely, you can also add the Powershell task before IIS manage task and run delete script.
Here is the sample script to delete local files:
Remove-Item -Path "D:\Websites2\*"
You can replace "D:\Websites2\*" as your local website file path.

Resources