Azure Devops hosted Ubuntu agent cancels build with edited hosts file - azure-devops

If I edit the hosts file using the Ubuntu agent the build just cancels all together. Had no such issue with Host Linux agent. Any ideas?
Have tried using npm package hostile to edit the hosts file, and through terminal using sudo tee.

Related

Azure Self-hosted Windows agent hook

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:

Use DevOps Release Pipeline to Upload Artifacts to a Linux Server

Is there a simple way to upload build artifacts in a zip file to a Linux Server using SCP or some other protocol?
Right now the build sits in a specific directory on the build server ready to be uploaded but the docs I've been reading haven't made it clear how to upload it to Linux using DevOps Release Pipeline. The documentation and question/answers I've been reading appears to be windows to windows rather than windows to Linux.
Thanks!
Is there a simple way to upload build artifacts in a zip file to a Linux Server using SCP or some other protocol?
You could try to use Copy Files Over SSH task to copy the Artifacts to a Linux Server.
Use this task in a build or release pipeline to copy files from a
source folder to a target folder on a remote machine over SSH.
This task allows you to connect to a remote machine using SSH and copy
files matching a set of minimatch patterns from specified source
folder to target folder on the remote machine. Supported protocols for
file transfer are SFTP and SCP via SFTP. In addition to Linux, macOS
is partially supported.
Please check the developer forum Copy Files Over SSH during Continuous Integration and Deployment for some more details.

Using Azure DevOps with Ansible

I want to deploy an Ansible playbook through Azure DevOps but the Ansible extension requires us to have a Linux VM configured with Ansible in order to deploy our playbook. Is there a way to deploy the Ansible playbook through Azure DevOps withougt needing to configure a Linux VM first?
To run this Ansible extension, Linux VM just be one of choice. If you don't want use VM, you can choose another method: Private Linux agent.
Just install a private linux agent in your Linux machine.
Then during the pipeline configuration, select Agent machine.
This method do not need you create a linux VM and create SSH endpoint with that VM. Just install linux agent into machine, then the pipeline can run with that.
Note:
Do not forget the prerequisites: The Playbook and Inventory files be located on a private Linux agent.

How to use Azure Pipelines to remote to Azure Ubuntu Server VM then do deployment?

I would like to use Azure Ubuntu Server for deployment through Azure Pipelines.
The flow that I want below but don't know how to do this:
When there is new update in Git-Hub dev branch, trigger Pipelines to perform:
Remote Azure Ubuntu Server (with UI interface)
Close running process in Terminal
Download files from Git-Hub Repository
Re-run process in Terminal
Steps that have been done
Procedure to create Ubuntu Server VM in Azure Portal:
Create Ubuntu Server VM in Azure Portal
Add inbound rule (port 3389 for RDP) (Reference link)
SSH to Ubuntu Server VM like ssh user#138.30.xx.xxx
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install lxde -y
sudo apt-get install xrdp -y
/etc/init.d/xrdp start
Remote through RDP from Mac/Windows (can copy files easily):
sudo apt-get install -f
sudo apt-get -y install nodejs
sudo apt-get -y install npm
sudo apt-get -y install chromium-browser
sudo apt-get -y update
sudo apt-get -y upgrade
After Setup environment:
Start process in Terminal with below command:
node node.js
I can think of below three different ways to do this that you can give them a try.
1, Use SSH task to run scripts in a remote machine( Azure Ubuntu Server).
First you need to add a SSH service connection to your azure organization. Please check here for steps how to create new service connection and here for the settings of SSH service connection.
Then You need to create a empty build pipeline and add the SSH task. Choose the SSH service connection you have created in above step, then you can run your custom commands in the commands field. Check here for example steps to create a build pipeline. Below screenshot is in classic UI view.
2, Install a self-hosted agent on your Azure Ubuntu Server and run your build pipeline on this agent.
Firstly, check here for detailed steps to create a self-hosted linux agent.
Secondly, create a build pipeline and choose your self agent pool which has your self-hosted agent. So that the tasks and commands will run on your Azure Ubuntu Server
Then you can add bash task to run your custom scripts. or add other tasks according to your project.
3, Create a deployment agent on your https://www.azuredevopslabs.com/labs/vstsextend/deploymentgroups/
You can follow the detailed steps here to create a deployment group and provision the agent.
Here is simply example about how to user deployment group in your release pipeline
Addition:To enable CI build for each new update to Git-Hub dev branch. You need to enable the CI trigger in your build pipeline.
Go to the edit page your pipeline, choose Triggers and enable Continuous Integration
Hope above helps!

VSTS CI push images to Linux remote server

I have an ASP.NET Core solution and I am using Visual Studio Team Services Continuous Integration to build and push the images into the Azure Container registries repositories. Until now all are fine; now I am trying some way to push those images to a Linux Ubuntu Server that is also hosted in Azure, but the PowerShell on Target Machines won't execute the script to the remote server.
There are any way to make the server load the new images when they are available?
You can use the dedicated Docker tasks, which are cross-platform, or you can use SSH task to run a script on a Linux machine using SSH.