Azure Self-hosted Windows agent hook - azure-devops

In Azure DevOps we have a Pipeline and Release created and working. In the release, we have the Azure Self-hosted Windows agent running and publishing to the off-site server without any issues.
Once the agent has completed deployment of the website, we would like to run a script on the Self-hosted server. (example POST HOOK COMMAND > C:\srvscripts\azure-post-hook.ps1)
Where can configure the agent to run a script once the website is published?

Where can configure the agent to run a script once the website is published?
If you want to run a script once the website is published on the on the Self-hosted server, you could add a powershell task after the task your deployment the website:
Since you are running the script on the Self-hosted server, we could directly specify the path C:\srvscripts\azure-post-hook.ps1 where the script is located in the scripts path option:

Related

How to copy files from a linux agent to windows agent in Azure DevOps release pipeline?

I have to run a Linux docker image for performing testing in Azure DevOps release pipeline. Hence, I have used;
Agent Pool : Azure Pipelines and Agent Specification: ubuntu-20.04
for that task. Now, result of this test has to be send as an email. For that 'Send Email' extension in Azure DevOps marketplace can be used. But this is configured only for Windows agent.
So, there is a requirement to run two agent jobs, one for Linux and other Windows. How can I access the report file generated in first job, to send email in second.
Had tried publishing pipeline artifacts, but it didn't worked as artifacts are not supported in release.

Publishing remote test results to my Azure DevOps pipeline

I have a nodejs web application that I build in Azure Pipelines. I am planning to deploy the generated artifacts on a Azure VM (probably a dev test labs), as part of one of the pipeline steps.
I want to now run browser tests by pointing the browser to the hosted URL in the Azure VM. I want to use the Azure windows and linux VMs in a build pipeline to run the tests on this remote Azure VM and publish the results to the pipeline. These would be karma tests essentially running on the nodejs server.
In my current design, the test results are going to be available on the Azure VM hosting the nodejs application.
What I don't understand is how can I get these test results back to
the Azure Pipeline for publishing the same?
Is there a way I can architect this solution without having to setup my Azure VM as a
pipeline agent in Azure DevOps?
Is there a standard pattern to design such continuous test infrastructure using Azure DevOps?
Thanks
According to your description, you just want to use Microsoft host agent to access an url on your self-host agent (ignore it's Azure VM or your own physical machine, same to host agent).
It depends if that url are accessible through public internet.
The simplest solution here is deploy your build agent on that Azure VM directly. Then run build and test. You can do this through the following script and tasks:
run ng test or any command to raise your tests
publish test results with PublishTestResults task
publish code coverage results with PublishCodeCoverageResults task
Microsoft-hosted agent pool will not work for you with every scenarios. For many teams this is the simplest way to run your jobs. You can try it first and see if it works for your build or deployment. If not, you can use a self-hosted agent. Self-hosted agents give you more control for your builds, tests and deployments.
In your scenario, setup your Azure VM as a pipeline agent and run build/test on it should be the simplest and convenient solution.

Creating release pipeline to several VMs

I have multiple ASP.NET web applications which I want to release into different VMs. Manually installing a DevOps agent in every single VM seems really inefficient. Is there a way to make this process faster? Is it possible to create release pipeline that could directly push the code to the public ip of the VM?
As workaround, you can prepare scripts to register each new agent. Here you can find parameters: Self-hosted Windows agents - Unattended config.
If you deploy your web application with IIS deployment task,
You can have a try using task Manage IIS, which can create website in a remote machine.
And then you can add a Windows machine file copy task to copy the build artifacts to the website Physical path in the remote machine.
Another workaround is that you can manage IIS with powershell script. So that you can add task PowerShell on target machines to run powershell script to manage IIS website. You can refer the example scripts at this page, and this page. For more information about IIS powrshell command you can refer here

how to deploy an application to a particular ubuntu server using azure-devops?

I have my code in the azure repos.I have created the release pipeline which runs the task "npm install" and "npm run start".This will deploy my application.But I want to deploy this application to my ubuntu server 206.189.22.155 from the azure release pipeline.Is there any way I can configure the release pipeline to use my ubuntu server?
The only agent pool available for me is "Azure Pipelines" and for agent specification I used "ubuntu-16.04".Iam totally confused about how this works.
I just want my application to run on http://206.189.22.155:5000. I can run the application directly in the server, but the whole point is to run it from the release pipeline.So how do I connect the pipeline to my ubuntu server?I think my default azure uses some kind of virtual machine for deployment.
You can create a deployment group in Azure DevOps. Deployment groups in Azure pipelines make it easier to organize the servers you want to use to host your app. In Azure pipelines -> Devployment group, select “+New” button and type of target to register. Copy and run the Registration script in your Ubuntu server.
You can refer to https://learn.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-linuxvm-deploygroups?view=azure-devops&tabs=java-script#define-your-ci-build-pipeline and https://learn.microsoft.com/en-us/azure/devops/pipelines/release/deployment-groups/index?view=azure-devops for more detailed information
After you create the deployment group, you can choose it in your release pipeline
And after you configure you deployment group, you can deploy your app to the specific server.

Are there seperate VSTS agents for build vs release?

I am getting my first VSTS build and release definitions setup.
Test server destination, on prem
project is using VS 2017 professional
Earlier I setup a private agent for doing the build, following this.
https://learn.microsoft.com/en-us/vsts/build-release/actions/agents/v2-windows?view=vsts
The agent installed fine and I can see it from build & release / agent pools
However, have now switched to using a hosted agent for that so I can remove the need to install visual studio on a test server.
Now I want to deploy the build to my test server, which is on premises. Do I need yet another agent or can I use the one I setup already. In other words are build agents separate from release agents? The agent I setup earlier is running as a service.
The build agent can be used in VSTS build and release, also the deployment group agent is configuring with build agent too.
You don’t need to setup another build/release agent, there are many tasks to deploy app to another server, such as IIS Web App Deployment Using WinRM, PowerShell on Target machine, Windows Machine File Copy.
The build and release agents are the same, but you have to install an on-premise agent to deploy your projects in your network. Is not that you can not use the hosted agent, but you would have to use WinRM and open you network, which may not be a good idea.
After you installed your on-premise agent, you don't have to install VS on the machine to run tests. You can add the following task to your release.