Jenkins Agent

  • By Jenkins CI Charmers
Channel Version Revision Published Runs on
latest/stable 5 5 10 May 2021
Ubuntu 20.04
juju deploy jenkins-ci-charmers-jenkins-agent
Show information


Jenkins Agent Operator

A Juju charm deploying and managing Jenkins Agent on Kubernetes, configurable to use a Jenkins charm deployed in another Juju model, or to connect to a standalone Jenkins instance.


Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.

For documentation on Jenkins itself, see here.


For details on using Kubernetes with Juju see here, and for details on using Juju with MicroK8s for easy local testing see here.

The charm supports cross-model relations to connect to a Juju-deployed Jenkins instance in another model. We'll use this to deploy a Jenkins instance and connect our Jenkins Agent to it.

First we're going to bootstrap and deploy Juju on LXC. We'll later add our MicroK8s model to this same controller.

juju bootstrap localhost lxd
juju deploy jenkins

Then go to the jenkins interface by visiting $JENKINS_IP:8080 in a browser, and logging in with the admin credentials which can be retrieved as follows:

juju run-action jenkins/0 --wait get-admin-credentials

You can configure the plugins you want, and either create an initial admin user or skip that and continue with the pre-created one.

Now we're going to create our k8s model and generate a cross-model relation offer:

microk8s.config | juju add-k8s micro --controller=lxd
juju add-model jenkins-agent-k8s micro
juju deploy cs:~jenkins-ci-charmers/jenkins-agent

The charm status will be "Blocked" with a message of "Missing required config: jenkins_agent_name jenkins_agent_token jenkins_master_url". This will be fixed by creating and accepting our cross-model relation. We do this from within the k8s model:

juju offer jenkins-agent:slave
# The output will be something like:
#  Application "jenkins-agent" endpoints [slave] available at "admin/jenkins-agent-k8s.jenkins-agent"

Switch back to your IaaS model where you deployed jenkins and run:

# Adjust based on the output of your 'juju offer' command above
juju add-relation jenkins <your-controller>:admin/<your-microk8s-model>.jenkins-agent

You can now visit $JENKINS_IP:8080/computer/ in a browser and you'll see the jenkins agent has been added to your jenkins instance.

For more details see here.