Jenkins Agent

  • By Alexandre Gomes
juju deploy jenkins-agent-k8s
Show information
You will need Juju 2.9 to be able to run this command. Learn how to upgrade to Juju 2.9.
Channel Version Revision Published Base
latest/stable 3 3 21 May 2021
20.04
latest/edge 3 3 25 May 2021
20.04

Platform:

About

Agent for Jenkins, the leading open source automation server. Jenkins provides hundreds of plugins to support building, deploying and automating any project. Read more


Relevant links


Discuss this charm

Share your thoughts on this charm with the community on discourse.

Join the discussion

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.

Overview

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.

Usage

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.