-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1185 from opendevstack/experimental
Show Jenkins master/agent errors in the boxes, when they do not work as expected.
- Loading branch information
Showing
14 changed files
with
306 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
ME="$(basename $0)" | ||
JAVA_INSTALLED_PKGS_LOGS="/tmp/java_installed_pkgs.log" | ||
JAVA_11_INSTALLED_PKGS_LOGS="/tmp/java_11_installed_pkgs.log" | ||
rm -fv ${JAVA_INSTALLED_PKGS_LOGS} ${JAVA_11_INSTALLED_PKGS_LOGS} | ||
|
||
NEEDS_DEVEL=${1-""} | ||
PKG_NAME_TAIL="headless" | ||
if [ ! -z "${NEEDS_DEVEL}" ] && [ "" != "${NEEDS_DEVEL}" ]; then | ||
NEEDS_DEVEL="true" | ||
PKG_NAME_TAIL="devel" | ||
else | ||
NEEDS_DEVEL="false" | ||
PKG_NAME_TAIL="headless" | ||
fi | ||
|
||
echo "${ME}: Needs development packages? ${NEEDS_DEVEL}" | ||
echo " " | ||
echo "${ME}: Listing versions of java installed: " | ||
yum list installed | grep -i "\(java\|jre\)" | tee -a ${JAVA_INSTALLED_PKGS_LOGS} | ||
touch ${JAVA_11_INSTALLED_PKGS_LOGS} | ||
grep -i "java-11" ${JAVA_INSTALLED_PKGS_LOGS} > ${JAVA_11_INSTALLED_PKGS_LOGS} || echo "No java 11 packages found." | ||
|
||
NEEDS_INSTALLATION="true" | ||
if [ -f ${JAVA_11_INSTALLED_PKGS_LOGS} ]; then | ||
if grep -qi "${PKG_NAME_TAIL}" ${JAVA_11_INSTALLED_PKGS_LOGS} ; then | ||
NEEDS_INSTALLATION="false" | ||
fi | ||
fi | ||
|
||
# We need devel package in masters to have jar binary. | ||
if [ "true" == "${NEEDS_INSTALLATION}" ]; then | ||
echo "${ME}:Java-11 is *not* installed. Installing..." | ||
if [ "true" == "${NEEDS_DEVEL}" ]; then | ||
yum -y install java-11-openjdk-devel | ||
else | ||
yum -y install java-11-openjdk-headless | ||
fi | ||
else | ||
echo "${ME}: Java-11 is already installed." | ||
fi | ||
|
||
if grep -qi "java-1.8" ${JAVA_INSTALLED_PKGS_LOGS} ; then | ||
echo "${ME}: Java-8 is installed. Removing..." | ||
yum -y remove java-1.8* | ||
else | ||
echo "${ME}: Java-8 is not installed. Correct." | ||
fi | ||
|
||
rm -fv ${JAVA_INSTALLED_PKGS_LOGS} ${JAVA_11_INSTALLED_PKGS_LOGS} | ||
|
||
echo " " | ||
echo "${ME}: Checking java tool versions: " | ||
if [ "true" == "${NEEDS_DEVEL}" ]; then | ||
jar --version | ||
fi | ||
|
||
NO_JAVA_LINK="false" | ||
java -version || NO_JAVA_LINK="true" | ||
if [ "true" == "${NO_JAVA_LINK}" ]; then | ||
JAVA_HOME_FOLDER=$(ls -lah /usr/lib/jvm | grep "java-11-openjdk-11.*\.x86_64" | awk '{print $NF}' | head -1) | ||
JAVA_HOME="/usr/lib/jvm/${JAVA_HOME_FOLDER}" | ||
alternatives --set java ${JAVA_HOME}/bin/java | ||
fi | ||
java -version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
FILEPATH=${1-"/usr/local/bin/openshift-run-jnlp-client"} | ||
|
||
if [ ! -f ${FILEPATH} ]; then | ||
echo " " | ||
echo "ERROR: File does not exist: ${FILEPATH}" | ||
echo " " | ||
exit 1 | ||
fi | ||
|
||
sed -i 's|\#\!/bin/bash|\#\!/bin/bash -x|g' ${FILEPATH} | ||
sed -i "s|^\s*JAVA_TOOL_OPTIONS\s*=.*| echo 'WARNING: JAVA_TOOL_OPTIONS env variable is UNSET.'|g" \ | ||
${FILEPATH} | ||
sed -i "s|^\s*export\s*JAVA_TOOL_OPTIONS.*| echo 'WARNING: JAVA_TOOL_OPTIONS env variable is UNSET.'|g" \ | ||
${FILEPATH} | ||
sed -i 's|^\(\s*\)JAVA_GC_OPTS\s*=.*|\1JAVA_GC_OPTS=|g' ${FILEPATH} | ||
sed -i 's|curl\s*-sS\s*|curl -sSLv |g' ${FILEPATH} | ||
|
||
grep -B 3 -A 3 -i '\(bash\|JAVA_TOOL_OPTIONS\|JAVA_GC_OPTS\|curl\)' ${FILEPATH} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
ME="$(basename $0)" | ||
|
||
yum clean all || true | ||
rm -rf /var/cache/yum/* || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
ME="$(basename $0)" | ||
JAVA_INSTALLED_PKGS_LOGS="/tmp/java_installed_pkgs.log" | ||
JAVA_11_INSTALLED_PKGS_LOGS="/tmp/java_11_installed_pkgs.log" | ||
rm -fv ${JAVA_INSTALLED_PKGS_LOGS} ${JAVA_11_INSTALLED_PKGS_LOGS} | ||
|
||
NEEDS_DEVEL=${1-""} | ||
PKG_NAME_TAIL="headless" | ||
if [ ! -z "${NEEDS_DEVEL}" ] && [ "" != "${NEEDS_DEVEL}" ]; then | ||
NEEDS_DEVEL="true" | ||
PKG_NAME_TAIL="devel" | ||
else | ||
NEEDS_DEVEL="false" | ||
PKG_NAME_TAIL="headless" | ||
fi | ||
|
||
echo "${ME}: Needs development packages? ${NEEDS_DEVEL}" | ||
echo " " | ||
echo "${ME}: Listing versions of java installed: " | ||
yum list installed | grep -i "\(java\|jre\)" | tee -a ${JAVA_INSTALLED_PKGS_LOGS} | ||
touch ${JAVA_11_INSTALLED_PKGS_LOGS} | ||
grep -i "java-11" ${JAVA_INSTALLED_PKGS_LOGS} > ${JAVA_11_INSTALLED_PKGS_LOGS} || echo "No java 11 packages found." | ||
|
||
NEEDS_INSTALLATION="true" | ||
if [ -f ${JAVA_11_INSTALLED_PKGS_LOGS} ]; then | ||
if grep -qi "${PKG_NAME_TAIL}" ${JAVA_11_INSTALLED_PKGS_LOGS} ; then | ||
NEEDS_INSTALLATION="false" | ||
fi | ||
fi | ||
|
||
# We need devel package in masters to have jar binary. | ||
if [ "true" == "${NEEDS_INSTALLATION}" ]; then | ||
echo "${ME}:Java-11 is *not* installed. Installing..." | ||
if [ "true" == "${NEEDS_DEVEL}" ]; then | ||
yum -y install java-11-openjdk-devel | ||
else | ||
yum -y install java-11-openjdk-headless | ||
fi | ||
else | ||
echo "${ME}: Java-11 is already installed." | ||
fi | ||
|
||
if grep -qi "java-1.8" ${JAVA_INSTALLED_PKGS_LOGS} ; then | ||
echo "${ME}: Java-8 is installed. Removing..." | ||
yum -y remove java-1.8* | ||
else | ||
echo "${ME}: Java-8 is not installed. Correct." | ||
fi | ||
|
||
rm -fv ${JAVA_INSTALLED_PKGS_LOGS} ${JAVA_11_INSTALLED_PKGS_LOGS} | ||
|
||
echo " " | ||
echo "${ME}: Checking java tool versions: " | ||
if [ "true" == "${NEEDS_DEVEL}" ]; then | ||
jar --version | ||
fi | ||
|
||
NO_JAVA_LINK="false" | ||
java -version || NO_JAVA_LINK="true" | ||
if [ "true" == "${NO_JAVA_LINK}" ]; then | ||
JAVA_HOME_FOLDER=$(ls -lah /usr/lib/jvm | grep "java-11-openjdk-11.*\.x86_64" | awk '{print $NF}' | head -1) | ||
JAVA_HOME="/usr/lib/jvm/${JAVA_HOME_FOLDER}" | ||
alternatives --set java ${JAVA_HOME}/bin/java | ||
fi | ||
java -version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
ME="$(basename $0)" | ||
echo "${ME}: INFO: Fixing openshift scripts..." | ||
|
||
FILE_TO_MODIFY=${1-"/usr/libexec/s2i/run"} | ||
|
||
if [ -f ${FILE_TO_MODIFY} ]; then | ||
sed -i 's|\#\!/bin/bash|\#\!/bin/bash -x|g' ${FILE_TO_MODIFY} | ||
sed -i "s|^\s*JAVA_TOOL_OPTIONS\s*=.*| echo 'WARNING: JAVA_TOOL_OPTIONS env variable is UNSET.'|g" \ | ||
${FILE_TO_MODIFY} | ||
sed -i "s|^\s*export\s*JAVA_TOOL_OPTIONS.*| echo 'WARNING: JAVA_TOOL_OPTIONS env variable is UNSET.'|g" \ | ||
${FILE_TO_MODIFY} | ||
sed -i 's|^\(\s*\)JAVA_GC_OPTS\s*=.*|\1JAVA_GC_OPTS=|g' ${FILE_TO_MODIFY} | ||
grep -B 3 -A 3 -i '\(bash\|JAVA_TOOL_OPTIONS\|JAVA_GC_OPTS\)' ${FILE_TO_MODIFY} | ||
else | ||
echo " " | ||
echo "${ME}: WARNING: Could not modify file because it does not exist: ${FILE_TO_MODIFY} " | ||
echo " " | ||
echo " " | ||
fi | ||
|
||
echo "${ME}: INFO: Fixed openshift scripts." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
ME="$(basename $0)" | ||
echo "${ME}: Upgrading Jenkins to latest LTS version available..." | ||
|
||
# sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo | ||
# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key | ||
# sudo yum upgrade | ||
# Add required dependencies for the jenkins package | ||
# sudo yum install java-11-openjdk | ||
# sudo yum install jenkins | ||
# sudo systemctl daemon-reload | ||
|
||
DEFAULT_TARGET="/usr/lib/jenkins/jenkins.war" | ||
TARGET="${DEFAULT_TARGET}" | ||
|
||
curl -sSLO https://get.jenkins.io/war-stable/latest/jenkins.war | ||
|
||
if [ ! -f "${TARGET}" ]; then | ||
echo "${ME}: File does not exist: ${TARGET}" | ||
TARGET="$(find /usr/ -name jenkins.war)" | ||
echo "${ME}: New target: ${TARGET}" | ||
fi | ||
|
||
if [ -f "${TARGET}" ]; then | ||
echo "${ME}: Upgrading Jenkins to latest LTS version... " | ||
rm -fv ${TARGET} | ||
mv -vf jenkins.war ${TARGET} | ||
ls -lah ${TARGET} | ||
else | ||
echo "${ME}: ERROR: Cannot upgrade Jenkins version." | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "${DEFAULT_TARGET}" ]; then | ||
DEFAULT_TARGET_FOLDER="$(dirname ${DEFAULT_TARGET})" | ||
if [ ! -d ${DEFAULT_TARGET_FOLDER} ]; then | ||
mkdir -pv ${DEFAULT_TARGET_FOLDER} | ||
fi | ||
cd ${DEFAULT_TARGET_FOLDER} && ln -sv ${TARGET} . | ||
fi | ||
ls -la ${DEFAULT_TARGET} ${TARGET} | ||
echo "${ME}: INFO: Jenkins was upgraded to latest LTS version." | ||
|
Oops, something went wrong.