Azure Pipelines Run the agent with Docker.
A service that builds / deploys like Jenkins.
It is a daemon that actually operates the build and deploy process in response to instructions from Azure Pipelines.
Azure Pipelines comes with a free version, but there is a monthly run time limit. By preparing your own agent, you can use it without the maximum time.
See the URL for Azure DevOps. I think it looks like https://dev.azure.com/hogehoge
. This is the part of hogehoge
.
Personal Access Token
This is what the agent needs to connect to Azure DevOps.
Click here for [How to get Personal Access Token](https://docs.microsoft.com/ja-jp/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs = preview-page).
Set the following as the scope.
The official image of Micorosoft is Deprecated, so I created it though I'm afraid. sengokyu/azure-pipelines-agent:latest Pull as usual.
docker pull sengokyu/azure-pipelines-agent
At the time of execution, give the organization name and Personal Access Token prepared in advance as environment variables.
Variable name | value |
---|---|
ORG | Organization name |
TOKEN | Personal Access Token |
docker run -d -e TOKEN=${PAT} -e ORG=${ORG} sengokyu/azure-pipelines-agent
Deploy using an ARM template.
The resource definition part of the ARM template. The whole thing is on GitHub.
template.json
"resources": [
{
"name": "[parameters('containerGroupName')]",
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2019-12-01",
"location": "[resourceGroup().location]",
"properties": {
"containers": [
{
"name": "[parameters('agent')]",
"properties": {
"image": "[variables('containerImage')]",
"resources": {
"requests": {
"cpu": "[parameters('cpu')]",
"memoryInGb": "[parameters('memoryInGb')]"
}
},
"environmentVariables": [
{ "name": "TOKEN", "secureValue": "[parameters('token')]" },
{ "name": "ORG", "value": "[parameters('org')]" },
{ "name": "POOL", "value": "[parameters('pool')]" },
{ "name": "AGENT", "value": "[parameters('agent')]" }
]
}
}
],
"osType": "Linux",
"restartPolicy": "Never"
}
}
]
Create a file that describes each parameter.
parameters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"containerGroupName": { "value": "vsts-agent" },
"pool": { "value": "Default" },
"agent": { "value": "vsts-agent-on-aci" },
"token": { "value": "YourPersonalAccessToken" },
"org": { "value": "YourOrganizationName" },
"cpu": { "value": 4 },
"memoryInGb": { "value": 8 }
}
}
Execute the az command.
az deployment group create -f template.json -p @parameters.json -g ResourceGroupName
Recommended Posts