Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-48711] - Create a PCT Docker image, mostly works
- Loading branch information
1 parent
ae156ca
commit 4109ff4
Showing
4 changed files
with
166 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ reports | |
work/ | ||
^jenkins/ | ||
.idea | ||
out |
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,53 @@ | ||
# The MIT License | ||
# | ||
# Copyright (c) 2017 CloudBees, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
FROM maven:3.5.2-jdk-8 | ||
LABEL Description="Base image for running Jenkins Plugin Compat Tester (PCT) against custom plugins and Jenkins cores" Vendor="Jenkins project" | ||
|
||
# Local build | ||
COPY plugins-compat-tester-cli/target/ /pct/src/plugins-compat-tester-cli/target/ | ||
|
||
#TODO: Uncomment once Jenkins Artifactory is recovered | ||
# https://issues.jenkins-ci.org/browse/INFRA-1447 | ||
# Copy sources | ||
#COPY plugins-compat-tester/ /pct/src/plugins-compat-tester/ | ||
#COPY plugins-compat-tester-cli/ /pct/src/plugins-compat-tester-cli/ | ||
#COPY plugins-compat-tester-gae/ /pct/src/plugins-compat-tester-gae/ | ||
#COPY plugins-compat-tester-gae-client/ /pct/src/plugins-compat-tester-gae-client/ | ||
#COPY plugins-compat-tester-model/ /pct/src/plugins-compat-tester-model/ | ||
#COPY *.xml /pct/src/ | ||
#COPY LICENSE.txt /pct/src/LICENSE.txt | ||
|
||
#WORKDIR /opt/pct/src/ | ||
#RUN ls -l && mvn clean package | ||
|
||
ENV JENKINS_WAR_PATH=/pct/jenkins.war | ||
ENV PCT_OUTPUT_DIR=/pct/out | ||
ENV PCT_TMP=/pct/tmp | ||
|
||
COPY src/main/docker/run-pct.sh /usr/local/bin/run-pct | ||
|
||
VOLUME /pct/plugin-src | ||
VOLUME /pct/jenkins.war | ||
VOLUME /pct/out | ||
VOLUME /root/.m2 | ||
ENTRYPOINT ["run-pct"] |
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,77 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
|
||
if [ $# -eq 1 ]; then | ||
# if `docker run` only has one argument, we assume that the user is running an alternate command | ||
# like `bash` to inspect the image. All options passed to the executable shoud have at least 2 arguments. | ||
echo "Only one argument is specified, running a custom command" | ||
exec "$@" | ||
exit 0 | ||
fi | ||
|
||
### | ||
# Process arguments | ||
### | ||
if [ -n "${ARTIFACT_ID}" ]; then | ||
echo "Running PCT for plugin ${ARTIFACT_ID}" | ||
else | ||
echo "ERROR: Artifact ID is not specified. Use environment variable, e.g. \"-e ARTIFACT_ID=credentials\"" | ||
exit -1 | ||
fi | ||
|
||
if [ -n "${CHECKOUT_SRC}" ] ; then | ||
echo "Using custom checkout source: ${CHECKOUT_SRC}" | ||
else | ||
CHECKOUT_SRC="https://github.com/jenkinsci/${ARTIFACT_ID}-plugin.git" | ||
fi | ||
|
||
if [ -n "${VERSION}"] ; then | ||
VERSION="master" | ||
fi | ||
|
||
if [ -f "${JENKINS_WAR_PATH}" ]; then | ||
echo "Using custom Jenkins WAR from ${JENKINS_WAR_PATH}" | ||
mkdir -p "${PCT_TMP}" | ||
# WAR is accessed many times in the PCT runs, let's keep it local insead of pulling it from a volume | ||
cp "${JENKINS_WAR_PATH}" "${PCT_TMP}/jenkins.war" | ||
WAR_PATH_OPT="-war ${PCT_TMP}/jenkins.war " | ||
else | ||
WAR_PATH_OPT="" | ||
fi | ||
|
||
### | ||
# Checkout sources | ||
### | ||
mkdir -p "${PCT_TMP}/localCheckoutDir" | ||
cd "${PCT_TMP}/localCheckoutDir" | ||
if [ -e "/pct/plugin-src/pom.xml" ] ; then | ||
echo "Located custom plugin sources" | ||
mkdir "${ARTIFACT_ID}" | ||
cp -R /pct/plugin-src/* "${ARTIFACT_ID}/" | ||
# Due to whatever reason PCT blows up if you have work in the repo | ||
cd "${ARTIFACT_ID}" && mvn clean && rm -rf work | ||
else | ||
echo "Checking out from ${CHECKOUT_SRC}:${VERSION}" | ||
git clone "${CHECKOUT_SRC}" | ||
mv $(ls .) ${ARTIFACT_ID} | ||
cd ${ARTIFACT_ID} && git checkout "${VERSION}" | ||
fi | ||
|
||
### | ||
# Run PCT | ||
### | ||
cd /pct | ||
PCT_CLI=$(ls src/plugins-compat-tester-cli/target/plugins-compat-tester-cli-*.jar ) | ||
if [ -e "${PCT_CLI}" ] ; then | ||
echo "Using PCT CLI ${PCT_CLI}" | ||
else | ||
echo "Failed to locate PCT CLI" | ||
exit -1 | ||
fi | ||
|
||
mkdir -p "${PCT_TMP}/work" | ||
mkdir -p "${PCT_OUTPUT_DIR}" | ||
|
||
# The image always uses external Maven due to https://issues.jenkins-ci.org/browse/JENKINS-48710 | ||
exec java -jar ${PCT_CLI} -reportFile ${PCT_OUTPUT_DIR}/pct-report.xml -workDirectory "${PCT_TMP}/work" ${WAR_PATH_OPT} -skipTestCache true -localCheckoutDir "${PCT_TMP}/localCheckoutDir/${ARTIFACT_ID}" -includePlugins "${ARTIFACT_ID}" -mvn "/usr/bin/mvn" "$@" |