Installation

Follow this guide to stand up Friendly Jenkins on a single machine (master) and prepare agents for Docker Compose deployments.

Requirements

  • Jenkins Master: 2–4 vCPUs (4+ recommended), 4–8 GB RAM, 20–50 GB SSD, Linux/macOS/Windows with Docker.

  • Jenkins Agent (per node): 4–8 vCPUs, 8–16 GB RAM, 100–500 GB SSD, Linux (Ubuntu 20.04+, Debian 11+, CentOS/RHEL 8+).

  • Network: TCP 443 through nginx (UI), 50000 (agents), outbound HTTPS to registries, outbound Git if syncing shared library.

  • Optional: Harbor registry, GitLab for webhooks, SMTP, LDAP/AD.

  • Docker 20.10 → 24.x

  • Docker Compose 2.0 → 2.23+

  • Git 2.30 → 2.43+

  • Jenkins LTS 2.426.1 → latest LTS

Install Docker

Use your OS package manager:

  • Ubuntu/Debian: add Docker APT repo, install docker-ce + docker-compose-plugin, add your user to docker group.

  • CentOS/RHEL: add Docker YUM repo, install docker-ce + plugins, enable service.

  • macOS: install Docker Desktop via Homebrew (brew install --cask docker) or official download.

Verify:

docker --version
docker compose version

Publish images once to Harbor and pull them everywhere (no local builds on testers’ machines):

  1. Build and push master image:

    cd jenkins-master
    docker login hub.friendly-tech.com -u "$HARBOR_USER" -p "$HARBOR_PASS"
    docker build -t hub.friendly-tech.com/qa-jenkins/friendly-jenkins-master:latest .
    docker push hub.friendly-tech.com/qa-jenkins/friendly-jenkins-master:latest
  2. Build and push agent image:

    cd jenkins-agent
    docker login hub.friendly-tech.com -u "$HARBOR_USER" -p "$HARBOR_PASS"
    docker build -t hub.friendly-tech.com/qa-jenkins/qa-agent:latest .
    docker push hub.friendly-tech.com/qa-jenkins/qa-agent:latest
  3. In the compose examples below, use image: hub.friendly-tech.com/qa-jenkins/friendly-jenkins-*:latest to pull from Harbor.

Master Setup (one-time)

If the master already runs, skip to Agent setup.

  1. Files you need on the master host (copy from your bundle or artifact store):

    • jenkins-master/docker-compose.yml

    • jenkins-master/casc.yaml

    • jenkins-master/.env (create from the example below; never commit it)

    • jenkins-master/init.groovy.d/ and jenkins-master/pipelines/

    • Optional: shared-library/ (if you want to mount it read-only)

    • Optional: dependencies.drawio for reference

Minimal layout:

/opt/friendly-jenkins/
├── jenkins-master/
│   ├── docker-compose.yml
│   ├── casc.yaml
│   ├── .env            # you create this
│   └── ...             # other supporting files
└── shared-library/     # optional mount for live edits

Use these examples if you need to recreate files from scratch.

Example: master docker-compose.yml

The master runs on the external Docker network harbor_harbor, next to the nginx-proxy container.

services:
  jenkins:
    image: hub.friendly-tech.com/qa-jenkins/friendly-jenkins-master:latest
    container_name: jenkins-qa-master
    restart: unless-stopped
    # Runs as uid 1000. No docker.sock: QA environments run on agents.
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL
    env_file:
      - .env
    environment:
      # 8080 is not published: nginx-proxy reaches it over harbor_harbor.
      JENKINS_OPTS: "--httpPort=8080 --httpListenAddress=0.0.0.0"
      JAVA_OPTS: "-Xmx2g -Xms1g -Djenkins.install.runSetupWizard=false"
      PLUGINS_FORCE_UPGRADE: "true"
    volumes:
      - ./data:/var/jenkins_home
      - ./casc.yaml:/var/jenkins_home/casc.yaml:ro
      - ./init.groovy.d:/usr/share/jenkins/ref/init.groovy.d:ro
      - ./pipelines:/var/jenkins_home/jenkins/pipelines/:ro
    networks:
      - harbor_harbor
    ports:
      - "50000:50000"

networks:
  harbor_harbor:
    external: true

Example: master .env

JENKINS_ADMIN_USER=admin
JENKINS_ADMIN_PASS=<generate: openssl rand -base64 24>
# Further administrators: comma-separated Jenkins user IDs
JENKINS_ADMINS=
JENKINS_URL=https://jenkins.friendly-tech.com
JENKINS_PORT=8080
JENKINS_AGENT_PORT=50000

# Optional registry
HARBOR_USER=robot$jenkins-qa
HARBOR_PASS=robot-token

# Optional Git for shared library sync
GIT_USER=git-username
GIT_PASS=git-token

# Optional SMTP
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=jenkins@example.com
SMTP_PASS=app-password

# Optional webhook secret
WEBHOOK_SECRET_EXPECTED=SHLIB_WEBHOOK_SECRET
  1. Prepare the data folder. The controller runs as uid 1000, and Docker would otherwise create these paths as root:

    cd jenkins-master
    mkdir -p data/jenkins/pipelines data/qa-data
    touch data/casc.yaml
    sudo chown -R 1000:1000 data
  2. Start Jenkins on the master:

    docker compose pull
    docker compose up -d
    docker compose logs -f jenkins
    docker exec nginx-proxy nginx -s reload

    Wait for: Jenkins is fully up and running.

  3. Access the UI through nginx, with JENKINS_ADMIN_USER / JENKINS_ADMIN_PASS from .env. Port 8080 is not published on the host, so nginx is the only way in.

  4. As admin, finish the first-time setup:

    • Run each job under QA-Environments/ and QA-Application-Templates/ once. The first run registers its parameters.

    • In Manage Jenkins → In-process Script Approval, review and approve the pending scripts. Until then, the fields of Build with Parameters stay on Loading…​, and only an administrator can approve them.

    • Create the user accounts. See Access and permissions.

First Run Verification

After startup, the following Jenkins folders should exist automatically:

  • QA-Application-Templates/ — template CRUD jobs.

  • QA-Environments/ — create, deploy, update, stop, delete, backup jobs.

  • QA-System/ — system and shared-library sync jobs.

Check Manage Jenkins → System → Global Pipeline Libraries for the qa-shared library pointing to your Git repository.

Agent Setup (repeatable per host)

An agent connects a QA server to the Jenkins server. The Jenkins UI says "controller" for the Jenkins server. QA engineers install agents on their own servers. The steps in Jenkins need administrator rights. Some QA engineers have these rights.

agent-setup

An agent secret is a credential. Do not paste it into tickets, chats, or screenshots.

An agent mounts docker.sock, so it has root access to its host. Use agent hosts only for QA.

Prerequisites on the QA Server

  • Docker and Docker Compose. The user must have permission to run Docker.

  • Network access to Jenkins through nginx. If nginx has an allow-list, add the host IP address.

  • Network access to TCP port 50000 on the host of JENKINS_URL. Agents do not use nginx for this port.

  • The /opt/qa-envs folder. The Compose user must own this folder. Each environment gets a folder here.

  • At least one port tool: ss, netstat or lsof. Without a tool, pipelines do not detect port conflicts.

To install the port tools on Debian or Ubuntu:

sudo apt-get update && sudo apt-get install -y iproute2 net-tools lsof

To install the port tools on Red Hat Enterprise Linux (RHEL) or CentOS:

sudo yum install -y iproute net-tools lsof

Files on the QA Server

You can start the agent stack from any folder. Only /opt/qa-envs has a fixed path.

  • jenkins-agent/docker-compose.yml: from this repository or your bundle.

  • jenkins-agent/.env: the node name and secret. See the example below.

  • jenkins-agent/data-agent/: an empty folder for the agent workspace.

Example layout before docker compose up -d:

/usr/jenkins/agent/
├── docker-compose.yml
├── .env
└── data-agent/

Get the agent secret via Jenkins UI

These steps need administrator rights.

  1. In Jenkins, go to Manage Jenkins → Nodes.

    Nodes list

  2. Create a node or open an existing node:

    • Enter any node name and select Permanent Agent.

    • Set Remote root directory, for example /home/jenkins/agent. The compose file maps this path into the container.

    • Set the labels. The default label is qa.

    • Set the launch method to Launch agent by connecting it to the controller.

    • Click Save.

  3. Open the node.

    Agent details and command

    While the agent is offline, the page shows Run from agent command line:

    curl -sO https://jenkins.friendly-tech.com/jnlpJars/agent.jar;
    java -jar agent.jar -url https://jenkins.friendly-tech.com/ -secret <SECRET> -name <agent> -workDir "/home/jenkins/agent"

    Do not run this command. The agent starts from the Compose file below. The agent image has the Docker command line and yq for deployments.

  4. Copy <agent> to JENKINS_AGENT_NAME and <SECRET> to JENKINS_AGENT_SECRET in .env.

  5. To keep the new node, run the node sync (syncNodesConfigStep). The sync writes the node to casc.yaml.

    A node only in the UI can disappear when Jenkins restarts. For who runs the sync and how, verify with the QA team.

The page says "Agent is connected" and shows no command. This is normal: Jenkins shows the command only while an agent is offline. To read the secret of a connected agent, use one of these methods.

curl -u '<user>:<api-token>' https://jenkins.friendly-tech.com/computer/<agent>/jenkins-agent.jnlp

Or use the Script Console through an SSH tunnel to the master container. nginx blocks the Script Console.

println jenkins.model.Jenkins.get().getComputer('<agent>').jnlpMac

Example: agent docker-compose.yml

services:
  jenkins-agent:
    image: hub.friendly-tech.com/qa-jenkins/qa-agent:latest
    container_name: jenkins-qa-agent
    restart: unless-stopped
    env_file: .env
    user: "0:0"
    volumes:
      - ./data-agent:/home/jenkins/agent
      - /var/run/docker.sock:/var/run/docker.sock
      # Environments live under /opt/qa-envs on the host
      - /opt/qa-envs:/opt/qa-envs
    command: >
      -url ${JENKINS_URL}
      ${JENKINS_AGENT_SECRET}
      ${JENKINS_AGENT_NAME}
    network_mode: host
    # For non-host networking:
    # ports: []
    # networks: [jenkins_network]

    # networks:
    #   jenkins_network:
    #     driver: bridge

Example: agent .env

# Agent Settings
JENKINS_AGENT_NAME=node-name
JENKINS_AGENT_SECRET=secret
JENKINS_AGENT_WORKDIR=/path-to-jenkins-agent
# Through nginx: port 8080 of the master is not published
JENKINS_URL=https://jenkins.friendly-tech.com

Start the agent:

cd jenkins-agent
docker compose pull
docker compose up -d
docker compose logs -f jenkins-agent

The log should end with INFO: Connected, and the node should show as online in Manage Jenkins → Nodes. If it does not, see Agent does not connect.

The image is built for both amd64 and arm64. To update an agent, repeat docker compose pull and docker compose up -d.