Standardize/Update Headers, Use Declarative Paths
Updated the headers so they would be standardized to follow the same
conventions as used in the build-jenkins.sh.
Changed the sourcing of the kubernetes-launch.sh, now will use a
declarative path instead of the relative paths.
Had a few comment changes I felt were better explanations.
Change-Id: I8fa44443b5eeb893ba93b0be5d7cadae14a63c08
Signed-off-by: Alanny Lopez <alannyglopez@gmail.com>
diff --git a/build-jenkins.sh b/build-jenkins.sh
index 91f032e..9d41bc9 100755
--- a/build-jenkins.sh
+++ b/build-jenkins.sh
@@ -1,56 +1,65 @@
#!/bin/bash
################################################################################
+#
# Script used to create a Jenkins master that can run amd64 or ppc64le. It can
# be used to launch the Jenkins master as a Docker container locally or as a
# Kubernetes Deployment in a Kubernetes cluster.
+#
################################################################################
-# Launch Variables:
-# These variables are used to determine how the master will be launched
-# workspace The directory that hold files used to deploy the Jenkins
-# master
-# Default: "${HOME}/jenkins-build-${RANDOM}"
-# launch Method in which the container will be launched, either as
-# a Docker container launched via Docker or by using a
-# helper script to launch into Kubernetes (docker or k8s)
-# Default: "docker"
-# home_mnt The directory on the host used as the Jenkins home
+#
+# Script Variables:
+# build_scripts_dir The path of the openbmc-build-scripts directory.
+# Default: The directory containing this script
+# workspace The directory that holds files used to build the Jenkins
+# master master image and volumes used to deploy it.
+# Default: "~/jenkins-build-${RANDOM}"
+#
+# Jenkins Dockerfile Variables:
+# agent_port The port used as the Jenkins slave agent port.
+# Default: "50000"
+# http_port The port used as Jenkins UI port.
+# Default: "8080"
+# img_tag The tag of the OpenJDK image used as the base image.
+# Default: "/8-jdk"
+# j_vrsn The version of the Jenkins war file you wish to use.
+# Default: "2.60.3"
+# j_user Username tag the container will use to run Jenkins.
+# Default: "jenkins"
+# j_group Group name tag the container will use to run Jenkins.
+# Default: "jenkins"
+# j_uid Jenkins user ID the container will use to run Jenkins.
+# Default: "1000"
+# j_gif Jenkins group ID the container will use to run Jenkins.
+# Default: "1000"
+# j_home Directory used as the Jenkins Home in the container.
+# Default: "/var/jenkins_home"
+# out_img The name given to the Docker image when it is built.
+# Default: "openbmc/jenkins-master-${ARCH}:${JENKINS_VRSN}"
+# tini_vrsn The version of Tini to use in the Dockerfile, 0.16.1 is
+# the first release with ppc64le release support.
+# Default: "0.16.1"
+#
+# Deployment Variables:
+# cont_import_mnt The directory on the container used to import extra files.
+# Default: "/mnt/jenkins_import", ignored if above not set
+# home_mnt The directory on the host used as the Jenkins home.
# Default: "${WORKSPACE}/jenkins_home"
-# host_import_mnt The directory on the host used to import extra files
-# Default: "", variable ignored by default
-# cont_import_mnt The directory on the container used to import extra files
-# Default: "/mnt/jenkins_import", will be ignored by default
+# host_import_mnt The directory on the host used to import extra files.
+# Default: "", import mount is ignored if not set
# jenkins_options What will be passed as the environment variable for the
# JENKINS_OPTS environment variable.
# Default: "--prefix=/jenkins"
# java_options What will be passed as the environment variable for the
# JAVA_OPTS environment variable.
# Default: "-Xmx4096m"
-# Build Variables:
-# img_tag The tag for the OpenJDK image used to build the Dockerfile
-# Default: "/8-jdk"
-# tini_vrsn The version of Tini to use in the dockerfile, 0.16.1 is
-# the first release with ppc64le release support
-# Default: "0.16.1"
-# j_vrsn The version of the Jenkins war file you wish to use
-# Default: "2.60.3"
-# j_user Username tag the container will use to run Jenkins
-# Default: "jenkins"
-# j_group Group name tag the container will use to run Jenkins
-# Default: "jenkins"
-# j_uid Jenkins user ID the container will use to run Jenkins
-# Default: "1000"
-# j_gif Jenkins group ID the container will use to run Jenkins
-# Default: "1000"
-# j_home Directory used as the Jenkins Home in the container
-# Default: "/var/jenkins_home"
-# http_port The port used as Jenkins UI port
-# Default: "8080"
-# agent_port The port used as the Jenkins slave agent port
-# Default: "50000"
-# out_img The name given to the Docker image when it is built
-# Default: "openbmc/jenkins-master-${ARCH}:${JENKINS_VRSN}"
+# launch docker|k8s
+# Method in which the container will be launched. Either as
+# a Docker container launched via Docker, or by using a
+# helper script to launch into a Kubernetes cluster.
+# Default: "docker"
#
################################################################################
+build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
set -xeo pipefail
ARCH=$(uname -m)
@@ -251,5 +260,5 @@
# launch using the k8s template
echo "Not yet Implemented"
exit 1
- source ./kubernetes/kubernetes-launch.sh Build-Jenkins false false
+ source ${build_scripts_dir}/kubernetes/kubernetes-launch.sh Build-Jenkins false false
fi
diff --git a/build-setup.sh b/build-setup.sh
index 09d87df..6ec337c 100755
--- a/build-setup.sh
+++ b/build-setup.sh
@@ -6,41 +6,55 @@
#
###############################################################################
#
-# Variables used for Jenkins build job matrix:
-# target = barreleye|palmetto|witherspoon|firestone|garrison|evb-ast2500
-# zaius|romulus|qemu
-# distro = fedora|ubuntu
-# imgtag = Varies by distro. latest|16.04|14.04|trusty|xenial; 23|24|25
-# obmcext = Path of the OpenBMC repo directory used in creating a copy
-# inside the container that is not mounted to external storage
-# default directory location "${WORKSPACE}/openbmc"
-# builddir = Path of the OpenBMC directory where the build occurs inside
-# the container, cannot be placed on external storage default
-# directory location "/tmp/openbmc"
-# sscdir = Path of the BitBake shared-state cache directoy, will default
-# to directory "/home/${USER}", used to speed up builds.
-# WORKSPACE = Path of the workspace directory where some intermediate files
-# and the images will be saved to.
+# Script Variables:
+# build_scripts_dir The path of the openbmc-build-scripts directory.
+# Default: The directory containing this script
+# http_proxy The HTTP address of the proxy server to connect to.
+# Default: "", proxy is not setup if this is not set
+# WORKSPACE Path of the workspace directory where some intermediate
+# files and the images will be saved to.
+# Default: "~/{RandomNumber}"
#
-# extraction = Path where the ombcdir contents will be copied out to when
-# the build completes. Defaults to ${obmcext}/build/tmp.
+# Docker Image Build Variables:
+# BITBAKE_OPTS Set to "-c populate_sdk" or whatever other bitbake options
+# you'd like to pass into the build.
+# Default: "", no options set
+# builddir Path where the actual bitbake build occurs in inside the
+# container, path cannot be located on network storage.
+# Default: "/tmp/openbmc"
+# distro The distro used as the base image for the build image:
+# fedora|ubuntu
+# Default: "ubuntu"
+# imgname The name given to the target build's docker image.
+# Default: "openbmc/${distro}:${imgtag}-${target}-${ARCH}"
+# imgtag The base docker image distro tag:
+# ubuntu: latest|16.04|14.04|trusty|xenial
+# fedora: 23|24|25
+# Default: "latest"
+# target The target we aim to build:
+# barreleye|evb-ast2500|firestone|garrison|palmetto|qemu
+# romulus|witherspoon|zaius
+# Default: "qemu"
#
-# Optional Variables:
-# launch = job|pod
-# Can be left blank to launch via Docker if not using
-# Kubernetes to launch the container.
-# Job lets you keep a copy of job and container logs on the
-# api, can be useful if not using Jenkins as you can run the
-# job again via the api without needing this script.
-# Pod launches a container which runs to completion without
-# saving anything to the api when it completes.
-# imgname = Defaults to a relatively long but descriptive name, can be
-# changed or passed to give a specific name to created image.
-# http_proxy = The HTTP address for the proxy server you wish to connect to.
-# BITBAKE_OPTS = Set to "-c populate_sdk" or whatever other bitbake options
-# you'd like to pass into the build.
+# Deployment Variables:
+# extraction Path where the ombcdir contents will be copied out to when
+# the build completes.
+# Default: "${obmcext}/build/tmp"
+# launch ""|job|pod
+# Can be left blank to launch the container via Docker
+# Job lets you keep a copy of job and container logs on the
+# api, can be useful if not using Jenkins as you can run the
+# job again via the api without needing this script.
+# Pod launches a container which runs to completion without
+# saving anything to the api when it completes.
+# obmcext Path of the OpenBMC repo directory used as a reference
+# for the build inside the container.
+# Default: "${WORKSPACE}/openbmc"
+# sscdir Path to use as the BitBake shared-state cache directory.
+# Default: "/home/${USER}"
#
###############################################################################
+build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
# Trace bash processing. Set -e so when a step fails, we fail the build
set -xeo pipefail
@@ -330,7 +344,7 @@
elif [[ "${launch}" == "job" || "${launch}" == "pod" ]]; then
# Source and run the helper script to launch the pod or job
- . ./kubernetes/kubernetes-launch.sh OpenBMC-build true true
+ . ${build_scripts_dir}/kubernetes/kubernetes-launch.sh OpenBMC-build true true
else
echo "Launch Parameter is invalid"
diff --git a/kubernetes/kubernetes-launch.sh b/kubernetes/kubernetes-launch.sh
index 1273af1..3917a92 100755
--- a/kubernetes/kubernetes-launch.sh
+++ b/kubernetes/kubernetes-launch.sh
@@ -19,38 +19,55 @@
# - Image pull secret exists for image pulls in Kubernetes cluster namespace
#
###############################################################################
-# Variables used to create Kubernetes Job:
-# namespace = the namespace to be used within the Kubernetes cluster
-# registry = the registry to use to pull and push images
-# imgplsec = the image pull secret used to access registry if needed
-# jobtimeout = the amount of time in seconds that the build will wait for
-# the job to be created in the api of the cluster.
-# podtimeout = the amount of time in seconds that the build will wait for
-# the pod to start running on the cluster.
-# imgname = the name the image that will be passed to the kubernetes api
-# to build the containers. The image with the tag imgname will
-# be built in the invoker script. This script will then tag it
-# to include the registry in the name, push it, and update the
-# imgname to be what was pushed to the registry. Users should
-# not include the registry in the original imgname.
-# podname = the name of the pod, will be needed to trace down the logs
+# Script Variables:
+# build_scripts_dir The path for the openbmc-build-scripts directory.
+# Default: The parent directory containing this script
+#
+# Kubernetes Variables:
+# imgplsec The image pull secret used to access registry if needed
+# Default: "regkey"
+# imgrepo The registry to use to pull and push images
+# Default: "master.cfc:8500/openbmc/""
+# jobtimeout The amount of time in seconds that the build will wait for
+# the job to be created in the api of the cluster.
+# Default: "60"
+# namespace The namespace to be used within the Kubernetes cluster
+# Default: "openbmc"
+# podtimeout The amount of time in seconds that the build will wait for
+# the pod to start running on the cluster.
+# Default: "600"
+#
+# YAML File Variables (No Defaults):
+# imgname The name the image that will be passed to the kubernetes
+# api to build the containers. The image with the tag
+# imgname will be built in the invoker script. This script
+# will then tag it to include the registry in the name, push
+# it, and update the imgname to be what was pushed to the
+# registry. Users should not include the registry in the
+# original imgname.
+# podname The name of the pod, needed to trace down the logs.
+#
+# Deployment Option Variables (No Defaults):
+# invoker Name of what this script is being called by or for, used
+# to determine the template to use for YAML file.
+# launch Used to determine the template used for the YAML file,
+# normally carried in by sourcing this script in another
+# script that has declared it.
+# log If set to true the script will tail the container logs
+# as part of the bash script.
+# purge If set to true it will delete the created object once this
+# script ends.
+# workaround Used to enable the logging workaround, when set will
+# launch a modified template that waits for a command. In
+# most cases it will be waiting to have a script run via
+# kubectl exec. Required when using a version of Kubernetes
+# that has known issues that impact the retrieval of
+# container logs when using kubectl. Defaulting to be true
+# whenever logging is enabled until ICP upgrades their
+# Kubernetes version to a version that doesn't need this.
#
###############################################################################
-# Variables that act as script options:
-# invoker = name of what this script is being called by or for, used to
-# determine the template to use for YAML file
-# log = set to true to make the script tail the container logs of pod
-# purge = set to true delete the created object once script completes
-# launch = used to determine the template for YAML file, Usually brought
-# in by sourcing from another script but can be declared
-# workaround = Used to enable the logging workaround, when set will launch a
-# modified template that waits for a command. In most cases it
-# will be waiting to have a script run via kubectl exec. Needed
-# when using a version of Kubernetes that has known issues that
-# impact the retrieval of container logs when using kubectl.
-# Defaulting to be true whenever logging is enabled until ICP
-# upgrades their Kubernetes version.
-###############################################################################
+build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."}
# Kubernetes Variables
namespace=${namespace:-openbmc}
@@ -115,7 +132,7 @@
extras+="-v2"
fi
-yamlfile=$(eval "echo \"$(<./kubernetes/Templates/${invoker}-${launch}${extras}.yaml)\"")
+yamlfile=$(eval "echo \"$(<${build_scripts_dir}/kubernetes/Templates/${invoker}-${launch}${extras}.yaml)\"")
kubectl create -f - <<< "${yamlfile}"
# If launch is a job we have to find the podname with identifiers
diff --git a/qemu-build.sh b/qemu-build.sh
index 33a2a00..ea61393 100755
--- a/qemu-build.sh
+++ b/qemu-build.sh
@@ -6,29 +6,38 @@
#
###############################################################################
#
-# Variables used for in the build:
-# WORKSPACE = Path of the workspace directory where some intermediate files
-# and the images will be saved to.
-# qemudir = Path of the directory that holds the QEMU repo, if none
-# exists will clone in the OpenBMC/QEMU repo to WORKSPACE.
-# builddir = Path of the directory that is created within the docker
-# container where the build is actually done. Done this way to
-# allow external volumes to be used for the qemudir.
+# Script Variables:
+# build_scripts_dir The path of the openbmc-build-scripts directory.
+# Default: The directory containing this script
+# http_proxy The HTTP address of the proxy server to connect to.
+# Default: "", proxy is not setup if this is not set
+# qemudir Path of the directory that holds the QEMU repo, if none
+# exists will clone in the OpenBMC/QEMU repo to WORKSPACE.
+# Default: "${WORKSPACE}/qemu"
+# WORKSPACE Path of the workspace directory where some intermediate
+# files and the images will be saved to.
+# Default: "~/{RandomNumber}"
#
-# Optional Variables:
-# launch = job|pod
-# Can be left blank to launch via Docker if not using
-# Kubernetes to launch the container.
-# Job lets you keep a copy of job and container logs on the
-# api, can be useful if not using Jenkins as you can run the
-# job again via the api without needing this script.
-# Pod launches a container which runs to completion without
-# saving anything to the api when it completes.
-# imgname = Defaults to qemu-build with the arch as its tag, can be
-# changed or passed to give a specific name to created image.
-# http_proxy = The HTTP address for the proxy server you wish to connect to.
+# Docker Image Build Variables:
+# builddir Path of the directory that is created within the docker
+# container where the build is actually done. Done this way
+# to allow NFS volumes to be used as the qemudir.
+# Default: "/tmp/qemu"
+# imgname Defaults to qemu-build with the arch as its tag, can be
+# changed or passed to give a specific name to created image
+#
+# Deployment Variables:
+# launch ""|job|pod
+# Leave blank to launch via Docker if not using kubernetes
+# to launch the container.
+# Job lets you keep a copy of job and container logs on the
+# api, can be useful if not using Jenkins as you can run the
+# job again via the api without needing this script.
+# Pod launches a container which runs to completion without
+# saving anything to the api when it completes.
#
###############################################################################
+build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
# Trace bash processing
set -x
@@ -160,9 +169,7 @@
-t ${imgname} \
${WORKSPACE}/build.sh
elif [[ "${launch}" == "pod" || "${launch}" == "job" ]]; then
- . ./kubernetes/kubernetes-launch.sh QEMU-build true true
+ . ${build_scripts_dir}/kubernetes/kubernetes-launch.sh QEMU-build true true
else
echo "Launch Parameter is invalid"
fi
-
-