Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

My custom Azure Pipelines agent as a Container image

Notifications You must be signed in to change notification settings

mathieu-benoit/my-azure-pipelines-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

my-azure-pipelines-agent

This repository contains the definition of my custom Azure Pipelines agent as a Docker image. I'm installing Docker, Azure CLI and Terraform on that agent.

Run the agent on Docker

AZP_TOKEN=FIXME
AZP_URL=https://dev.azure.com/FIXME
AZP_AGENT_NAME=myadoagent
AZP_POOL=myadoagent

docker run \
  -e AZP_URL=$AZP_URL \
  -e AZP_TOKEN=$AZP_TOKEN \
  -e AZP_AGENT_NAME=$AZP_AGENT_NAME \
  -e AZP_POOL=$AZP_POOL \
  -it mabenoit/ado-agent:latest

Note: if you need to run Docker on that Docker agent, you will need to add that parameter in the above command: -v /var/run/docker.sock:/var/run/docker.sock

Run the agent on ACI

AZP_TOKEN=FIXME
AZP_URL=https://dev.azure.com/FIXME
AZP_AGENT_NAME=myadoagent
AZP_POOL=myadoagent

az container create \
  -g $rg -n $name \
  --image mabenoit/ado-agent:latest \
  --ip-address Private \
  -e AZP_URL=$AZP_URL AZP_TOKEN=$AZP_TOKEN AZP_AGENT_NAME=$AZP_AGENT_NAME AZP_POOL=$AZP_POOL

Note: you canno't run Docker on that Docker agent, in other word youcan't add that parameter in the above command: -v /var/run/docker.sock:/var/run/docker.sock

Run the agent on Kubernetes

AZP_TOKEN=FIXME
AZP_URL=https://dev.azure.com/FIXME
AZP_AGENT_NAME=myadoagent
AZP_POOL=myadoagent

kubectl create secret generic azp \
  --from-literal=AZP_URL=$AZP_URL \
  --from-literal=AZP_TOKEN=$AZP_TOKEN \
  --from-literal=AZP_AGENT_NAME=$AZP_AGENT_NAME \
  --from-literal=AZP_POOL=$AZP_POOL

kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ado-agent
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ado-agent
  template:
    metadata:
      labels:
        app: ado-agent
    spec:
      containers:
        - name: ado-agent
          image: mabenoit/ado-agent:latest
          env:
            - name: AZP_URL
              valueFrom:
                secretKeyRef:
                  name: azp
                  key: AZP_URL
            - name: AZP_TOKEN
              valueFrom:
                secretKeyRef:
                  name: azp
                  key: AZP_TOKEN
            - name: AZP_AGENT_NAME
              valueFrom:
                secretKeyRef:
                  name: azp
                  key: AZP_AGENT_NAME
            - name: AZP_POOL
              valueFrom:
                secretKeyRef:
                  name: azp
                  key: AZP_POOL
          volumeMounts:
            - mountPath: /var/run/docker.sock
              name: docker-socket-volume
      volumes:
        - name: docker-socket-volume
          hostPath:
            path: /var/run/docker.sock
EOF

Resources

Releases

No releases published

Packages

No packages published