How do you publish files back to VSTS Release Management as part of a release? - azure-devops

I'm trying to upload log files created by a 3rd party exe during a deployment and including it in the results of my deployment, on a separate tab if possible.
I tried using the publish artifact build tasks but that only works for build not release.
I tried logging tasks but ##vso[build.uploadlog]<local file path> seems to be for builds as well since it complains about finding a container for the build.

Release management does not have a container for build artifacts, that's why you see this error message.
You can try with following task:
Write-host "##vso[task.uploadfile]<filename>"
View and download attachments associated with releases
Would you like to upload additional logs or diagnostics or images when
running tasks in a release? This feature enables users to upload
additional files during deployments. To upload a new file, use the
following agent command in your script:
Write-host "##vso[task.uploadfile]"
The file is then available as part of the release logs. When you
download all the logs associated with the release, you will be able to
retrieve this file as well.
You can also add a powershell script task in your release definition to read the log files and output it to the console. Then you will be see the content of the log files from "Logs" tab powershell script step. And you can also click "Download all logs as zip" to download the logs.

I hope to provide more clarity to those looking for an answer. The accepted answer does work.
I had a lot of files (browser screenshots) to add to the release logs. Here's what I did:
If you have lots of files, Archive them into a zip.
Attach the zip to the log files via powershell.
Download the logs
Unzip and enjoy!

#DonRolling, thanks for the detailed answer. In my case instead of adding a new task to compress the folder i just included that part in the powershell:
Compress-Archive -Path "$(System.DefaultWorkingDirectory)/TestFolder/ScreenShots" -DestinationPath "$(System.DefaultWorkingDirectory)/TestFolder/ScreenShots" -Force
Write-host "##vso[task.uploadfile]$(System.DefaultWorkingDirectory)/TestFolder/ScreenShots.zip"

I was facing a similar problem but I also wanted to use the Artifacts in a subsequent agent phase.
Based on the previous answers I created an Extension that offers the possibility to:
Upload a file or a folder to the Release Logs
Automatically download an Artifact from the logs that was previously uploaded
The upload task is making use of the logging command as it was mentioned before. The download task then queries the Azure DevOps REST Api to download all logs collected thus far, tries to find the specified artifact and copies it to a specific place.
If anyone is interested, it can be found on the Marketplace

Related

Azure devops release pipeline runs forever with error: The process cannot access the file because it is being used by another process

I'm running a deployment on Azure pipelines and the release got stuck while copying files. This resulted in an unending process which is not desirable.
The error I received was:
ERROR 32 (0x00000020) Copying File
C:\azagent\A2_work\r3\a_mach1-light\build\MyProject\HtmlRenderer.dll
The process cannot access the file because it is being used by another
process.
I think this issue is not a permanent one since I've been able to successfully run the same release pipeline several times in the past but I want to figure out why it happens.
I've read several docs relating to Azure pipelines and troubleshooting on microsoft's website but none has been useful.
I've also tried to rerun the build pipeline so it could create another release but the issue still persists.
I'd be happy to get advice from anyone who has experienced this before.
Thanks
You can try restarting the "Azure Pipelines Agent (MyCompanyName.MyMachineName)" service on the machine which hosts your deployment agent. See below screenshot.
For more Troubleshooting steps:
Detect files and folders in use
You can use tools like Process Monitor and Process Explorer to find out what process is using this specific file. See this thread.
Anti-virus exclusion
Anti-virus software scanning your files can cause file or folder in use errors during a build or release. Adding an anti-virus exclusion for your agent directory and configured "work folder" may help to identify anti-virus software as the interfering process.
If you use Msbuild in your pipeline:
MSBuild and /nodeReuse:false
MSBuild and /maxcpucount:[n]
Check this document for more information above troubleshooting steps.

How do i make an .exe that users can download on a website?

I already made an build pipeline with CI and i got successful builds. I want my latest successful build to be released on a website where people can download an .exe file of the application. I find very little information about this on how to do this.
I am working with Azure DevOps.
That depends on your website upload method:
File share. Use the Copy Files task or Publish Build Artifacts task in you build definition.
FTP or another. Try to use PowerShell to publish your results with PowerShell task

copy files from azure file storage to azure website after release

I have files that need to be copied over to my website (azure website) after a deployment has been made. usually these files are server specific (I have multiple different servers for different releases), and usually in the past, before i used azure, i just had a backup folder with these files and a powershell script that i ran after deployment that just copied those files right over.
Now that i'm moving to azure, i'd like to keep this functionality. I'm interested in copying over these files into azure file storage, and then in my release task after azure website deployment, just copying from that file storage over into the site\wwwroot folder. I'm not really seeing an easy way to do this. Is there a release task i can use with this in mind?
Is there a release task i can use with this in mind?
Yes, we could use the Azure File Copy task. I also do a demo to copy the zip file to the azure storage. It works correctly on my side. Fore more information, please refer to the screenshot.
Note: If you don't want to zip the files, you could remove the Archive File task.
Test result:

VSTS: Save file from Release-Definition (as an artifact)

I cannot use the Publish Build Artifacts Task in a release-definition, I'm getting the following error:
ErrorHostTypeNotSupported: This task must run in a build to publish artifacts to Visual Studio Team Services/TFS.
So my question is:
How can I save a file from a release-definition?
Why I want to achieve this:
I'm using a Deploy to Kubernetes Task in my release definition (which deploys a microservice with a yaml file to azure aks), this yaml file is tokenized during the release (I'm replacing the build-id). So at the end, I want to be able to download this file for each release and to use it for a manual deployment (if necessary).
Thanks for your help.
There is no container for artifacts in Release Management, so you cannot use that task in Release.
As a workaround, you can use ##vso[task.uploadfile]local file path command in VSTS Task Logging Command to upload the file.
Upload user interested file as additional log information to the
current timeline record. The file shall be available for download
along with task logs.
To do this, add a powershell task in your release definition like below:
When you want to use the file, download the release logs as zip, the file will be included in it.

Programatically run a load test without having the app in VSTS source control

We're using an on-prem VCS and CI pipeline, and don't have plans to switch to VSTS right now. However, I'd be very interested in running cloud-based load-tests against our app as part of our CI pipeline. In order to do this, I'd have to be able to programmatically upload the loadtest script and invoke it from VSTS.
Is this possible?
Yes, it is possible, the workflow like this:
1.Create a valid loadtest file. You can use the load test file from an earlier run through Visual Studio for this.
2.Create a location to upload the file(s). This location is a drop folder on Azure Blob and is below referred to as "TestDrop".
3.Upload the loadtest file and any other files required for the run, this includes the webtest files, settings file, etc. to this location or "TestDrop".
4.Create a Test Run using the Testdrop from the previous step as all the files required for a run are now available at the drop location.
5.Start the run.
6.Once finished, download the results to your local machine. This will be a gzip file. Uncompress it to get the results file.
7.Use Visual Studio to view the downloaded results.
More information, you can refer to this article, which contains samples.