Azure Container Agent Plugin
Azure Container Agent Plugin can help you to run a container as an agent in Jenkins
How to install
You can install/update this plugin in Jenkins update center (Manage Jenkins -> Manage Plugins, search Azure Container Agents Plugin).
You can also manually install the plugin if you want to try the latest feature before it's officially released. To manually install the plugin:
-
Clone the repo and build:
mvn package
-
Open your Jenkins dashboard, go to Manage Jenkins -> Manage Plugins
-
Go to Advanced tab, under Upload Plugin section, click Choose File.
-
Select
azure-container-agents.hpi
in target folder of your repo, click Upload. -
Restart your Jenkins instance after install is completed.
Pre-requirements
- Service Principal: Create Service Principal via Azure CLI 2.0
- Kubernetes Cluster: Create Kubernetes in Azure
Configure the plugin
- Jenkins -> Manage Jenkins -> Configure System
- Press
Add a new cloud
and chooseAzure Container Service(Kubernetes)
- Specify
Cloud Name
and it should be unique. - Choose an existing
Azure Service Principal
or create a new credential. - Choose
Resource Group
andContainer Service Name
. - Specify
Namespace
- Choose an existing
ACS Credential
or create a new one. You can choose one of two different kinds of credentials:- SSH Username with private key
- Microsoft Azure Container Service
- Press Test Connection to make sure the configurations above are correct.
Configure the Pod Template
Although Kubernetes supports multi-containers in a Pod, but we only support one container per pod now.
Please ensure JenkinsURL, secret and nodeName passed to container via arguments or environment variables.
- Specify
Name
andLabels
- Choose a
Docker image
. Please note that the slave will connect with master via JNLP, so make sure JNLP installed in image. - If you use a private registry, you need to specify a credential and you have two choose:
- Use a Private Registry Secret. You need to create a Secret in your Kubernetes cluster in advance and then fill in the Secret name.
- Use a Private Registry Credential. You just need to fill in the credential and we will create a Secret for you.
- Specify a
Command
to override the EntryPoint or leave it blank. - Specify the
Arguments
.${rootUrl}
,${secret}
and${nodeName}
will be replace with JenkinsUrl, Secret and ComputerNodeName automatically. - Specify the
Working Dir
. It's the root dir of you job. - Add Environment Variables and Volumes
- Choose a retention strategy. You can get details in help.
- Check whether to run container in privileged mode.
- Specify Request / Limit of the resource Cpu / Memory. Find details in Managing Compute Resources for Containers