Skip to content

feat(launcher): honor configured JENKINS_HOME in agent script - #175

Open
yanksyoon wants to merge 5 commits into
feat/systemd-user-directivefrom
feat/honor-jenkins-home-env
Open

feat(launcher): honor configured JENKINS_HOME in agent script#175
yanksyoon wants to merge 5 commits into
feat/systemd-user-directivefrom
feat/honor-jenkins-home-env

Conversation

@yanksyoon

Copy link
Copy Markdown
Member

Overview

Stop hardcoding /var/lib/jenkins in the agent launcher script. Use the JENKINS_HOME environment variable supplied by the systemd unit.

Rationale

Rev 18 of this charm managed JENKINS_HOME via /etc/default/jenkins-slave. In the current charm the systemd unit is the source of truth for this path, but the launcher script ignored it and always used a fixed value. This PR makes the script honor the configured home while keeping a fallback default for backward compatibility.

Juju Events Changes

None.

Module Changes

  • templates/jenkins_agent.sh.j2: replaces readonly JENKINS_HOME="/var/lib/jenkins" with an environment-variable driven default.
  • src/service.py: passes jenkins_home to the script template so the default matches the configured home.
  • tests/unit/test_service.py: adds tests verifying the rendered script contains the configured or default home path.

Library Changes

None.

Checklist

  • The charm style guide was applied
  • The contributing guide was applied
  • The changes are compliant with ISD054 - Managing Charm Complexity
  • The documentation is updated
  • The PR is tagged with appropriate label (trivial, senior-review-required)
  • The changelog has been updated

Removes the hardcoded /var/lib/jenkins path in the launcher script and uses

the JENKINS_HOME environment variable. The unit already exports the configured

home. The script still falls back to /var/lib/jenkins if invoked directly,

preserving backward compatibility.
@yanksyoon
yanksyoon requested a review from a team as a code owner July 23, 2026 17:01
@yanksyoon
yanksyoon requested review from DeeKay3 and alithethird and removed request for a team July 23, 2026 17:01

@yhaliaw yhaliaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved


🤝 Human review with AI assistance.

yanksyoon and others added 4 commits August 10, 2026 13:30
* feat(service): ensure agent user exists and owns JENKINS_HOME

When agent_user is non-root, the charm now creates the user if missing and

ensures JENKINS_HOME is owned by that user. Failures are logged as warnings

so that pre-created users/homes do not block reconcile, matching the

warn-and-continue preference.

* feat(service): ensure agent user exists and owns JENKINS_HOME

Adds _ensure_user_and_home() to create the configured agent_user and chown

jenkins_home on every reconcile. Failures are logged and continue, honoring

the warn-and-continue preference. Unit tests use a fake useradd/pwd lookup

and assert os.chown arguments so they pass on macOS and in CI.

* feat(service): parameterize file ownership in _render_file (#177)

* feat(service): parameterize file ownership in _render_file

The previous implementation always chowned rendered files to root. This is

correct for systemd unit files and the launcher script (systemd runs as root),

but made it impossible for user-owned files to keep their owner. The helper

now accepts an optional owner argument so future code paths can render files

as the configured agent user while the service files remain root-owned.

* ci: debug

* feat: jenkins user w/ passwordless sudo

* ci: debug

* ci: revert debug

* ci(workflow): disable tmate debugging sessions

Tmate creates interactive tmux sessions that cannot be driven by automation.
Rely on captured Juju and pytest logs for diagnostics instead.

* test(integration): add diagnostics to traefik ingress test

Capture Jenkins client URL, Juju status, model debug logs and traefik
proxied endpoints when the Jenkins API connection drops during the
agent job-execution assertion. This helps identify whether the failure
is the server pod IP, ingress routing, or agent connectivity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants