Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-48711] - Add support of custom Java options and Remote Debug…
… to the image
  • Loading branch information
oleg-nenashev committed Dec 27, 2017
1 parent 8f04a91 commit 2e0571a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Expand Up @@ -46,6 +46,8 @@ ENV PCT_TMP=/pct/tmp

COPY src/main/docker/run-pct.sh /usr/local/bin/run-pct

EXPOSE 5005

VOLUME /pct/plugin-src
VOLUME /pct/jenkins.war
VOLUME /pct/out
Expand Down
15 changes: 14 additions & 1 deletion README.md
Expand Up @@ -34,6 +34,8 @@ Environment variables:
This is the only **mandatory** parameter.
* `VERSION` - tag/commit/branch to be checked out and tested. `master` by default
* `CHECKOUT_SRC` - Custom Git clone source (e.g. `https://github.com/oleg-nenashev/job-restrictions-plugin.git`). `https://github.com/jenkinsci/${ARTIFACT_ID}-plugin.git` by default
* `JAVA_OPTS` - Java options to be passed to the PCT CLI
* `DEBUG` - Boolean flag, which enables the Remote Debug mode (port == 5000)

Volumes:

Expand Down Expand Up @@ -66,7 +68,18 @@ You can run the CLI with the `-help` argument to get a full list of supported op

:exclamation: For the moment testing more than one plugin at once requires plugins to be released, so for testing SNAPSHOTS you need to execute the last step for every plugin you want to test*

## TODOs
## Developer Info

### Debugging PCT in Docker

If you need to debug a dockerized PCT instance,
use the `-e DEBUG=true -p 5005:5005` flags and then attach to the container using Remote Debugger in your IDE.

```
docker run --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -e ARTIFACT_ID=job-restrictions -e DEBUG=true -p 5005:5005 -i jenkins/pct
```

### TODOs

To do (refile in `plugin-compat-tester` in JIRA!):

Expand Down
10 changes: 9 additions & 1 deletion src/main/docker/run-pct.sh
Expand Up @@ -40,6 +40,14 @@ else
WAR_PATH_OPT=""
fi

extra_java_opts=()
if [[ "$DEBUG" ]] ; then
extra_java_opts+=( \
'-Xdebug' \
'-Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=y' \
)
fi

###
# Checkout sources
###
Expand Down Expand Up @@ -74,4 +82,4 @@ 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" "$@"
exec java ${JAVA_OPTS} ${extra_java_opts[@]} -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" "$@"

0 comments on commit 2e0571a

Please sign in to comment.