Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-48711] - Add support of running PCT against custom SNAPSHOT …
…wars.
  • Loading branch information
oleg-nenashev committed Dec 29, 2017
1 parent 2520521 commit 12b19a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -21,13 +21,13 @@ docker run --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -e ARTIFACT_ID=ss
```

This command will run PCT for the latest plugin version against the specified Jenkins WAR.
PCT supports running against SNAPSHOT builds, but PCT will have to install local Maven artifacts in such case.

```shell
docker run --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -v my/jenkins.war:/pct/jenkins.war:ro -e ARTIFACT_ID=ssh-slaves jenkins/pct
```

This command will run PCT against custom versions of Jenkins and the plugin specified by volumes.
Note that the current configuration requires the Jenkins core artifacts to be installed in the `maven-repo`.

```shell
docker run --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -v my/jenkins.war:/pct/jenkins.war:ro -v my/plugin:/pct/plugin-src:ro jenkins/pct
Expand Down
15 changes: 14 additions & 1 deletion src/main/docker/run-pct.sh
Expand Up @@ -35,11 +35,24 @@ if [ -z "${VERSION}" ] ; then
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 "
JENKINS_VERSION=$(unzip -q -c "${PCT_TMP}/jenkins.war" META-INF/MANIFEST.MF | grep 'Jenkins-Version' | cut -d ':' -f 2 | tr -d '[:space:]')
echo "Using custom Jenkins WAR v. ${JENKINS_VERSION} from ${JENKINS_WAR_PATH}"

if [[ "$JENKINS_VERSION" =~ .*SNAPSHOT.* ]]
then
cd "${PCT_TMP}"
echo "Version is a snapshot, will install artifacts to the local maven repo"
mkdir "war-exploded"
unzip -q -c "jenkins.war" "WEB-INF/lib/jenkins-core-${JENKINS_VERSION}.jar" > "war-exploded/jenkins-core.jar"
# unzip -q -c "jenkins.war" "WEB-INF/lib/jenkins-cli-${JENKINS_VERSION}.jar" > "war-exploded/jenkins-cli.jar"
mvn org.apache.maven.plugins:maven-install-plugin:2.5:install-file -Dfile="jenkins.war"
mvn org.apache.maven.plugins:maven-install-plugin:2.5:install-file -Dfile="war-exploded/jenkins-core.jar"
# mvn install:install-file -Dfile="war-exploded/jenkins-cli.jar"
fi
else
WAR_PATH_OPT=""
fi
Expand Down

0 comments on commit 12b19a7

Please sign in to comment.