Implement fully automated Jenkins HW8 setup with Ansible, JCasC and JJB
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /opt/jobs_uploader
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir jinja2 "setuptools<81" "jenkins-job-builder>=6.4.3"
|
||||
|
||||
COPY entrypoint.sh /opt/jobs_uploader/entrypoint.sh
|
||||
|
||||
RUN chmod +x /opt/jobs_uploader/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/opt/jobs_uploader/entrypoint.sh"]
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
export JENKINS_HOSTNAME="${JENKINS_HOSTNAME:?JENKINS_HOSTNAME is required}"
|
||||
export JENKINS_USERNAME="${JENKINS_USERNAME:?JENKINS_USERNAME is required}"
|
||||
export JENKINS_PASSWORD="${JENKINS_PASSWORD:?JENKINS_PASSWORD is required}"
|
||||
export JJB_PATH="${JJB_PATH:?JJB_PATH is required}"
|
||||
|
||||
cat > /tmp/jenkins-job-builder.ini <<EOF
|
||||
[job_builder]
|
||||
ignore_cache=True
|
||||
keep_descriptions=True
|
||||
recursive=True
|
||||
|
||||
[jenkins]
|
||||
url=${JENKINS_HOSTNAME}
|
||||
user=${JENKINS_USERNAME}
|
||||
password=${JENKINS_PASSWORD}
|
||||
EOF
|
||||
|
||||
echo "Waiting for Jenkins at ${JENKINS_HOSTNAME}..."
|
||||
until curl -fsS "${JENKINS_HOSTNAME}/login" >/dev/null; do
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "Uploading jobs from ${JJB_PATH}..."
|
||||
jenkins-jobs --conf /tmp/jenkins-job-builder.ini --flush-cache update "${JJB_PATH}"
|
||||
|
||||
echo "Jobs upload completed."
|
||||
Reference in New Issue
Block a user