Add the Continuous Integration with Jenkins chapter in the eight rubric sections: deployment and persistence (capacity test, memory-limit fix, restart test), HTTPS/access/firewall with IPv4 and IPv6 exposure checks, webhook traceability with an actual deployment diagram, pipeline stages, the required pr-main merge gate, PR #15's failure/repair/review/merge sequence, credentials and controller build boundary, and controls. Update the Hosts and Passwords tables (1 GiB resize, Jenkins and ci.yebilly.me, jenkins-bot account and token hints), the title page, abstract, Document History, glossary, and AI prompt log (including Vincent's prepared Oct 19-21 record). Note that Assignment 5's PR #13 merged. Also version pipeline-graph-view and its dependencies in the Jenkins plugin lockfile, and add Vincent's source-only ci/jenkins-capacity test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
3.9 KiB
Python
75 lines
3.9 KiB
Python
"""Resolve plugins on Windows Docker Desktop, never on the small droplet.
|
|
|
|
This launches only the official plugin installer, not Jenkins. The output is
|
|
non-secret plugin archives plus a hash/version manifest for the runtime test.
|
|
"""
|
|
import argparse
|
|
from datetime import datetime, timezone
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
import inventory
|
|
from run_test import IMAGE, LABEL, command, remove_owned
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--output", type=Path, required=True, help="NEW local plugin-bundle directory")
|
|
args = parser.parse_args()
|
|
if sys.platform != "win32":
|
|
parser.error("Prepare on Windows Docker Desktop; do not run this on the 512 MB droplet")
|
|
output = args.output.resolve()
|
|
if output.exists():
|
|
parser.error("Output already exists; preserve or review it before preparing another bundle")
|
|
bundle = Path(__file__).resolve().parent
|
|
owner = "prepare-" + datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ").lower()
|
|
container = None
|
|
output.mkdir(parents=True)
|
|
metadata = {"status": "INCOMPLETE", "environment": "Windows Docker Desktop plugin preparation only",
|
|
"base_image": IMAGE, "ram_mib": 768, "ram_plus_swap_mib": 1024,
|
|
"heap_max_mib": 512, "cpu": 1, "jenkins_started": False}
|
|
try:
|
|
if command("docker", "info", "--format", "{{.OSType}}").stdout.strip() != "linux":
|
|
raise RuntimeError("Use Docker Desktop's Linux engine")
|
|
if command("docker", "image", "inspect", IMAGE, check=False).returncode:
|
|
command("docker", "pull", IMAGE, timeout=300)
|
|
container = "ssw590-jenkins-" + owner
|
|
container = command("docker", "create", "--name", container,
|
|
"--label", f"{LABEL}={owner}", "--restart", "no",
|
|
"--memory", "768m", "--memory-swap", "1024m", "--cpus", "1", "--pids-limit", "256",
|
|
"--mount", f"type=bind,src={bundle},dst=/opt/ssw590-input,readonly",
|
|
"--env", "JAVA_OPTS=-Xms32m -Xmx512m -XX:+UseSerialGC",
|
|
"--entrypoint", "/bin/bash", IMAGE, "-c",
|
|
"mkdir -p /tmp/ssw590-prepared/plugins; "
|
|
"jenkins-plugin-cli --war /usr/share/jenkins/jenkins.war "
|
|
"--plugin-file /opt/ssw590-input/plugins.txt "
|
|
"--plugin-download-directory /tmp/ssw590-prepared/plugins --latest true --list "
|
|
"> /tmp/ssw590-prepared/installer.txt 2>&1").stdout.strip()
|
|
with (output / "preparer-process.txt").open("w") as log:
|
|
subprocess.run(["docker", "start", "--attach", container], stdout=log,
|
|
stderr=subprocess.STDOUT, timeout=900, check=True)
|
|
command("docker", "cp", container + ":/tmp/ssw590-prepared/plugins/.", str(output), timeout=60)
|
|
command("docker", "cp", container + ":/tmp/ssw590-prepared/installer.txt", str(output / "installer.txt"))
|
|
plugins = inventory.inventory(output, bundle / "plugins.txt")
|
|
(output / "manifest.json").write_text(json.dumps({"base_image": IMAGE, "plugins": plugins}, indent=2) + "\n")
|
|
(output / "plugins.lock").write_text("".join(p["id"] + ":" + p["version"] + "\n" for p in plugins))
|
|
metadata.update(status="PASS", plugin_count=len(plugins))
|
|
except Exception as error:
|
|
metadata.update(status="FAILED", reason=str(error))
|
|
if container:
|
|
command("docker", "cp", container + ":/tmp/ssw590-prepared/installer.txt",
|
|
str(output / "installer.txt"), check=False)
|
|
finally:
|
|
metadata["cleanup_ok"] = remove_owned(container, owner) if container else True
|
|
if not metadata["cleanup_ok"]:
|
|
metadata["status"] = "NEEDS_ATTENTION"
|
|
(output / "preparation.json").write_text(json.dumps(metadata, indent=2) + "\n")
|
|
print(json.dumps(metadata, indent=2))
|
|
return 0 if metadata["status"] == "PASS" else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|