Important: This plug-in is maintained by the Jenkins community and won’t be supported by Microsoft as of February 29, 2024.
Azure Container Agents Plugin can help you to run a container instance as an agent in Jenkins
You can install/update this plugin in Jenkins update center (Manage Jenkins -> Manage Plugins, search Azure Container Agents Plugin).
- Service Principal: Create Service Principal via Azure CLI 2.0
- or Managed Service Identity: Configure a VM Managed Service Identity (MSI) using the Azure portal
Azure Container Instances offers the fastest and simplest way to run a container in Azure, without having to provision any virtual machines and without having to adopt a higher-level service.
- Resource Group in available regions. Get region availability details.
- Jenkins -> Manage Jenkins -> Configure System
- Press
Add a new cloud
and chooseAzure Container Instance
- Specify
Cloud Name
and it should be unique. - Choose an existing
Azure Credential
or create a new credential. - Choose
Resource Group
.
- Specify
Name
andLabels
- Set
Startup Timeout
. - Select
Image OS Type
, Windows or Linux. - Fill in
Docker Image
. The default image isjenkins/inbound-agent
and you can also use it as base image. - If you use a private registry, you need to specify a credential.
- Specify a
Command
. Now theCommand
will override the ENTRYPOINT.Arguments
.${rootUrl}
,${secret}
,${instanceIdentity}
and${nodeName}
will be replaced with JenkinsUrl, Secret, Instance identity and ComputerNodeName automatically. - Specify the
Working Dir
. Ensure the user has write permission to this directory. - Add
Ports
,Environment Variables
andVolumes
as needed. - Choose a retention strategy. You can get details by clicking the help icon.
- Specify
CPU Requirement
andMemory Requirement
, ACI containers costs per second. Find more details in Container Instances pricing.
You can use the sample below in Manage Jenkins -> Script Console. The sample only contains a few arguments. Find all the arguments in the builders package.
import com.microsoft.jenkins.containeragents.builders.*
def myCloud = new AciCloudBuilder()
.withCloudName("mycloud")
.withAzureCredentialsId("<Your Credentials Id>")
.withResourceGroup("myResourceGroup")
.addNewTemplate()
.withName("mytemplate")
.withLabel("aci")
.addNewPort("80")
.addNewEnvVar("key","value")
.endTemplate()
.build()
Jenkins.get().clouds.add(myCloud)
//inherit template from existing template
import com.microsoft.jenkins.containeragents.builders.*
def baseTemplate = new AciContainerTemplateBuilder()
.withImage("privateImage")
.addNewPort("80")
.addNewEnvVar("key", "value")
.build()
def myCloud = new AciCloudBuilder()
.withCloudName("mycloud")
.withAzureCredentialsId("<Your Credentials Id>")
.withResourceGroup("myResourceGroup")
.addNewTemplateLike(baseTemplate)
.withName("mytemplate")
.withLabel("aci")
.endTemplate()
.build()
Jenkins.get().clouds.add(myCloud)
If you were previously using this plugin to integrate with AKS you should use the Kubernetes plugin instead.