Skip to content

Commit

Permalink
Jenkinsfile-Runner init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CSpicer-BAH committed Apr 28, 2021
1 parent 46c1078 commit eff83f9
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 0 deletions.
57 changes: 57 additions & 0 deletions jenkinsfile-runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ARG BASE_REGISTRY=registry.access.redhat.com
ARG BASE_IMAGE=ubi8/ubi
ARG BASE_TAG=8.3
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}

LABEL name="Solutions Delivery Platform: Jenkins Master" \
maintainer="[email protected]" \
vendor="Booz Allen Hamilton" \
version="1.0-beta-27" \
release="1.0-beta-27" \
summary="Jenkins pipeline execution engine packaged as a container" \
description="The Jenkins Master container image for the Solutions Delivery Platform"

COPY LICENSE /licenses

USER root

RUN INSTALL_PKGS="java-1.8.0-openjdk" && \
yum -y update-minimal --setopt=tsflags=nodocs \
--security && \
yum -y install --setopt=tsflags=nodocs ${INSTALL_PKGS}

ENV SDP_BUILD_DEPENDENCY_VERSION dcar-1.8
ARG TARBALL=jenkinsfile-runner-dependencies-${SDP_BUILD_DEPENDENCY_VERSION}
ENV JENKINS_UC https://updates.jenkins.io
ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/casc
ENV JENKINS_PM_VERSION 2.5.0
ENV JENKINS_PM_URL https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/${JENKINS_PM_VERSION}/jenkins-plugin-manager-${JENKINS_PM_VERSION}.jar
ENV JENKINSFILE_PATH ""
ARG JENKINS_HOME=/var/jenkins_home
ARG TMP_DIR=/var/groovy-tmpdir
ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000


RUN curl -sSLo /tmp/${TARBALL}.tar.gz https://github.com/boozallen/sdp-images/releases/download/${SDP_BUILD_DEPENDENCY_VERSION}/jenkinsfile-runner-dependencies-${SDP_BUILD_DEPENDENCY_VERSION}.tar.gz

RUN cd /tmp && tar -xzf ${TARBALL}.tar.gz \
&& mkdir -p $JENKINS_HOME $TMP_DIR /usr/share/jenkins /build \
&& mv dependencies/ref /usr/share/jenkins/ref \
&& mv dependencies/app /app \
&& rm -rf /tmp/* \
&& chown ${uid}:${gid} $JENKINS_HOME \
&& chown ${uid}:${gid} $TMP_DIR \
&& chown ${uid}:${gid} /app \
&& chown ${uid}:${gid} /usr/share/jenkins \
&& chown ${uid}:${gid} /build \
&& groupadd -g ${gid} ${group} \
&& useradd -d "$JENKINS_HOME" -d "$TMP_DIR" -d /app -d /usr/share/jenkins -u ${uid} -g ${gid} -m -s /bin/bash ${user}

VOLUME /build
VOLUME /usr/share/jenkins/ref/casc
VOLUME /usr/share/jenkins/ref/plugins

ENTRYPOINT ["/app/bin/jenkinsfile-runner-launcher"]
47 changes: 47 additions & 0 deletions jenkinsfile-runner/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Booz Allen Public License v1.0


### INTRODUCTION
The Booz Allen Public License allows government, non-profit academic, other non-profit, and commercial entities access to distinctive, disruptive, and robust code with the goal of Empowering People to Change the World℠. Products licensed under the Booz Allen Public License are founded on the basis that collective ingenuity can make the largest impact in the community.

### DEFINITIONS
* **Commercial Entity.** “Commercial Entity” means any individual or entity other than a government, non-profit academic, or other non-profit entity.
* **Derivative.** “Derivative” means any work of authorship in Source Code or Object Code form that results from an addition to, deletion from, or modification of the Source Code of the Product.
* **License.** “License” means this Booz Allen Public License.
* **Object Code.** “Object Code” means the form resulting from transformation or translation of Source Code into machine readable code, including but not limited to, compiled object code.
* **Originator.** “Originator” means each individual or legal entity that creates, contributes to the creation of, or owns the Product.
* **Patent Claims.** “Patent Claims” means any patent claim(s) in any patent to which Originator has a right to grant a license that would be infringed by Your making, using, selling, offering for sale, having made, or importing of the Product, but for the grant of this License.
* **Product.** “Product” means the Source Code of the software which the initial Originator made available under this License, and any Derivative of such Source Code.
* **Source Code.** “Source Code” means software in human-readable form.
* **You.** “You” means either an individual or an entity (if you are taking this license on behalf of an entity) that exercises the rights granted under this License.

### LICENSE
**Government/Non-Profit Academic/Other Non-Profit.**
This Section applies if You are not a Commercial Entity.

* **License.** Subject to the terms and conditions of this License, each Originator hereby grants You a perpetual, worldwide, non-exclusive, royalty-free license to reproduce, display, perform, modify, distribute and otherwise use the Product and Derivatives, in Source Code and Object Code form, in accordance with the terms and conditions of this License in order to support the general public good and for your internal business purposes.
* **Distribution.** You may distribute to third parties copies of the Product, including any Derivative that You create, in Source Code or Object Code form. If You distribute copies of the Product, including any Derivative that You create, in Source Code form, such distribution must be under the terms of this License and You must inform recipients of the Source Code that the Product is governed under this License and how they can obtain a copy of this License. You may distribute to third parties copies of the Product, including any Derivative that You create, in Object Code form, or allow third parties to access or use the Product, including any Derivative that You create, under a license of Your choice.
* **Commercial Sales.** You may not distribute, or allow third parties to access or use, the Product or any Derivative for a fee, unless You first obtain permission from the Originator. If Booz Allen Hamilton is the Originator, please contact Booz Allen Hamilton at <[email protected]>.

**Commercial Entities**.
This Section applies if You are a Commercial Entity.

* **License.** Subject to the terms and conditions of this License, each Originator hereby grants You a perpetual, worldwide, non-exclusive, royalty-free license to reproduce, display, perform, modify, distribute and otherwise use the Product and Derivatives, in Source Code and Object Code form, in accordance with the terms and conditions of this License for the sole purpose of Your internal business purposes and the provision of services to government, non-profit academic, and other non-profit entities.
* **Distribution and Derivatives.** You may distribute to third parties copies of the Product, including any Derivative that You create, in Source Code or Object Code form. If You distribute copies of the Product, including any Derivative that You create, in Source Code form, such distribution must be under the terms of this License and You must inform recipients of the Source Code that the Product is governed under this License and how they can obtain a copy of this License. You may distribute to third parties copies of the Product, including any Derivative that You create, in Object Code form, or allow third parties to access or use the Product, including any Derivative that You create, under a license of Your choice, provided that You make available, and inform the recipient of such distribution how they can obtain, a copy of the Source Code thereof, at no charge, and inform the recipient of the Source Code that the Product is governed under this License and how they can obtain a copy of this License.
* **Commercial Sales.** You may not distribute, or allow third parties to access or use, the Product or any Derivative for a fee, unless You first obtain permission from the Originator. If Booz Allen Hamilton, please contact Booz Allen Hamilton at <[email protected]>.

**Patent Claim(s)**.
This Section applies regardless of whether You are a government, non-profit academic, or other non-profit entity or a Commercial Entity.

* **Patent License.** Subject to the limitations in the Sections above, each Originator hereby grants You a perpetual, worldwide, non-exclusive, royalty-free license under Patent Claims of such Originator to make, use, sell, offer for sale, have made, and import the Product. The foregoing patent license does not apply (a) to any code that an Originator has removed from the Product, or (b) for infringement caused by Your modifications of the Product or the combination of any Derivative created by You or on Your behalf with other software.

### GENERAL TERMS
This Section applies regardless of whether You are a government, non-profit academic, or other non-profit entity or a Commercial Entity.

* **Required Notices.** If You distribute the Product or a Derivative, in Object Code or Source Code form, You shall not remove or otherwise modify any proprietary markings or notices contained within or placed upon the Product or any Derivative. Any distribution of the Product or a Derivative, in Object Code or Source Code form, shall contain a clear and conspicuous Originator copyright and license reference in accordance with the below:
* *Unmodified Product Notice*: “This software package is licensed under the Booz Allen Public License. Copyright © 20__ [Copyright Holder Name]. All Rights Reserved.”
* *Derivative Notice*: “This software package is licensed under the Booz Allen Public License. Portions of this code are Copyright © 20__ [Copyright Holder Name]. All Rights Reserved.”
* **Compliance with Laws.** You agree that You shall not reproduce, display, perform, modify, distribute and otherwise use the Product in any way that violates applicable law or regulation or infringes or violates the rights of others, including, but not limited to, third party intellectual property, privacy, and publicity rights.
* **Disclaimer.** You understand that the Product is licensed to You, and not sold. The Product is provided on an “As Is” basis, without any warranties, representations, and guarantees, whether oral or written, express, implied or statutory, with regard to the Product, including without limitation, warranties of merchantability, fitness for a particular purpose, title, non-infringement, non-interference, and warranties arising from course of dealing or usage of trade, to the maximum extent permitted by applicable law. Originator does not warrant that (i) the Product will meet your needs; (ii) the Product will be error-free or accessible at all times; or (iii) the use or the results of the use of the Product will be correct, accurate, timely, or otherwise reliable. You acknowledge that the Product has not been prepared to meet Your individual requirements, whether or not such requirements have been communicated to Originator. You assume all responsibility for use of the Product.
* **Limitation of Liability.** Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Originator, or anyone who distributes the Product in accordance with this License, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if informed of the possibility of such damages.
* **Severability.** If the application of any provision of this License to any particular facts or circumstances shall be held to be invalid or unenforceable, then the validity and enforceability of other provisions of this License shall not in any way be affected or impaired thereby.
41 changes: 41 additions & 0 deletions jenkinsfile-runner/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
OWNER = boozallen
REPO = sdp-images
IMAGE = jenkinsfile-runner
VERSION = dcar-1.8
JENKINS_VERSION=2.289

REGISTRY = docker.pkg.github.com/$(OWNER)/$(REPO)
TAG = $(REGISTRY)/$(IMAGE):$(VERSION)

.PHONY: help Makefile
.ONESHELL: push


# Put it first so that "make" without argument is like "make help".
help: ## Show target options
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

build: ## build container image
docker build . -t $(TAG)

push: ## builds and publishes container image
$(eval user := $(shell read -p "GitHub Username: " username; echo $$username))
$(eval pass := $(shell read -s -r -p "GitHub Token: " token; echo $$token))
@echo
@docker login $(REGISTRY) -u $(user) -p $(pass);
make build
docker push $(TAG)

build-dep: ## build container dependencies
$(eval dir := $(shell pwd))
docker run -it --rm -v $(dir)/prebuild:/root/prebuild --entrypoint /bin/bash jenkins/jenkinsfile-runner:latest /root/prebuild/transfer.sh
docker run -it --rm -u root -v $(dir)/prebuild:/root/prebuild jenkins/jenkins:${JENKINS_VERSION} /root/prebuild/pull-war.sh
docker run -it --rm -u root -v $(dir)/prebuild:/root/prebuild:z registry.access.redhat.com/ubi8/ubi:8.3 /root/prebuild/build-dep.sh

info:
@echo "$(TAG) -> $$(dirname $$(git ls-files --full-name Makefile))"

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
echo "Make command $@ not found"
49 changes: 49 additions & 0 deletions jenkinsfile-runner/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-------------
Jenkins Agent
-------------

A container image packaging the Jenkins pipeline execution engine, found under the `Jenkins open source project <https://github.com/jenkinsci/jenkinsfile-runner>`_

Synopsis
--------

To implement this repo locally, copy the repo to your machine.
From there open a command line, change your working directory to your copy of the repo, and use ``make build`` or ``docker build .`` to build the container image in the CLI.
Once the image is built, create a container using ``docker run image``.

The following sections are an explaination of the contents of repo.

Prereqs
-------

This repo makes use of UBI8 as the base image for the container derived from `RedHat <https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8/ubi>`_.
Additionally, this repo makes use of Docker for containers. If you do not wish to use Docker, please make edits to adapt to your implementation of container technology.
Lastly, you should ensure all files from the repo are present in your local copy.

Makefile
--------

The Makefile comes with the following commands: help, build, push, build-dep, info.
``make help`` will list available commands from the Makefile.
``make build`` will build a container image using the Dockerfile in the repo with the tag comprised of the application and version (application:version).
``make publish`` will build the container image and then publish the image to Github.
``make build-dep`` will generate a tarball containing the dependencies used by the image.
``make info`` will list the container registry and repo the image can be published to.
.. note:: using ``make publish`` provides no benefit by default to those outside of Booz Allen. Additionally, using ``make build-dep`` is unnecessary since the Dockerfile will obtain the needed tarball from Github.

Dockerfile
----------

This file is setup to generate a container image using ``docker build -t <TAG> .`` with the option to name the image as you wish.
The build process will consist of using a base image, copying the Booz Allen Public License, applying OpenShift labels, installing required packages and applications, establishing the user the container will run as, and setting a health check.

LICENSE
-------

This text file contains the Booz Allen Public License. Please read before using or distibuting this repo.

Prebuild
--------

This folder contains files and artifacts inherent to the creation of the container image.
These files and artifacts are used either in the ``make build-dep`` command or in authenticating the dependency tarball associated with the image.
52 changes: 52 additions & 0 deletions jenkinsfile-runner/prebuild/BAH-public.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN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r3kg8mUcNb8LTi4Fn9ITEv0COzPMOs7ibIMeFv+r5LGK2DHo/o+oLgSzNcx2W
PAzhFscXtCRFZHWjN1wLAjT1mPjkF8WRKfNwp3azU1VdZ4V7uR2FlsjwaL8QZs5g
ZpyeyZLMEsN47LoIaMvmTCc6HzsZoJAtz9GNwBlFmQoxodIkGYiwNRGWD/eNPEEA
EQEAAYkCJQQYAQIADwUCXjCitAIbDAUJEswDAAAKCRCRo0uHmCFZ3CyYEACN5wsX
vH+jNxYxQ+2FvObZyHT/LjD1DgFGCxE+dMqtaR84OgVgpHxhka8fbSaNlwey0J9h
jo7dgcx9pc4TpxmIiRFqKRUbMMEVfeksy1wC4T5UZHaL3QNy6I/vnpGmPkUmEK1F
RKERbpK/lCj4LDZpZr5hBnQ+5IcuSGR5JJ28vm58UMuiwwbE84hgbu0XcBqNkEcM
sg9jVVJJ7ZgV6TKjEa/335LwT8gQRBKBuef/ENWps8XOxY7tYD6XvHI4Hgxk5W3g
XuaaXs5SXR/bTgUgIYSqfSnjwbKVQJh8fXivs2N1kgFzZBA80O6oecB3+5sTmEMJ
SzBpX01+B0WQZ+AY/FAYTZhqG0eD0pn8MHdVr4emoZYAgkW9iCjrnN9+TS8Lpb0I
L3SxTyU07NCJKXZajCaSFuSm2OAM4E979HIZUargYKmA06v6bFXh/TdQKaONN+Eh
qR9E5AM1N12ekN0ORxSARRQuOXUMFZ+beco+MMGhkbtu4Q4dSJviF26gxgvdPDq9
5uMF/MKyo4Th6g1Yf3Y+UNaP9i+XHqvmExoDf6VN08Pto7sYIPHS1yqcEqJxPIw0
Q3R1n6FGi9YcfTSVpgLQa97FSzmzh5qT3Ef0puJsCzB916Itmwax1aeduZjURp3H
TWKZU0fI5Q5MLqyVTV3podyo7oDD4WySM3BYlQ==
=MD6X
-----END PGP PUBLIC KEY BLOCK-----
13 changes: 13 additions & 0 deletions jenkinsfile-runner/prebuild/build-dep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -xe

SDP_BUILD_DEPENDENCY_VERSION=dcar-1.8

cd /root/prebuild
tar czvf jenkinsfile-runner-dependencies-$SDP_BUILD_DEPENDENCY_VERSION.tar.gz dependencies
gpg --import /root/prebuild/BAH-public.key
gpg --import --allow-secret-key-import /root/prebuild/BAH-private.key
gpg --output /root/prebuild/jenkinsfile-runner-dependencies-$SDP_BUILD_DEPENDENCY_VERSION.sig --detach-sig /root/prebuild/jenkinsfile-runner-dependencies-$SDP_BUILD_DEPENDENCY_VERSION.tar.gz
sha256sum /root/prebuild/jenkinsfile-runner-dependencies-$SDP_BUILD_DEPENDENCY_VERSION.tar.gz | awk '{print $1}' > /root/prebuild/jenkinsfile-runner-dependencies-$SDP_BUILD_DEPENDENCY_VERSION.sha256
rm -rf /root/prebuild/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
228b4f3d88cb330036a915a8528f9636569807a16d7e4da177d6432fa9bcf5ed
Binary file not shown.
1 change: 1 addition & 0 deletions jenkinsfile-runner/prebuild/plugins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
templating-engine:2.2.2
Loading

0 comments on commit eff83f9

Please sign in to comment.