Skip to content

Commit

Permalink
Fix Pipeline as YAML support + Optimize the Docker rebuild (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev authored Jul 19, 2020
1 parent a426e0b commit 0723e2b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bootstrap/target
payload/target
payload-dependencies/target
setup/target
target/

# Tests
tests
Expand Down
10 changes: 9 additions & 1 deletion demo/pipeline-as-yaml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ Pipeline as YAML demo
This demo shows how to use [Pipeline as YAML](https://plugins.jenkins.io/pipeline-as-yaml/) in Jenkinsfile Runner.
It executes a simple "Hello, world!" Pipeline defined as YAML.

## Running in Docker

```bash
docker run --rm \
-v $(pwd)/Jenkinsfile.yml:/workspace/Jenkinsfile.yml \
jenkins4eval/jenkinsfile-runner:1.0-beta-14
```

## Running (without Docker)

Once Jenkinsfile Runner is built locally, the demo can be launched as...

```bash
java -jar ../../app/target/jenkinsfile-runner-standalone.jar -p ../../vanilla-package/target/plugins/ -w ../../vanilla-package/target/war/jenkins.war -f ./Jenkinsfile.yml
java -jar ../../app/target/jenkinsfile-runner-standalone.jar -p ../../vanilla-package/target/plugins/ -w ../../vanilla-package/target/war/jenkins.war -f ./Jenkinsfile.yml
```
14 changes: 8 additions & 6 deletions packaging/docker/unix/debian-jdk8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ FROM jenkins4eval/jenkinsfile-runner:build-mvncache as jenkinsfilerunner-mvncach
FROM maven:3.5.4 as jenkinsfilerunner-build
ENV MAVEN_OPTS=-Dmaven.repo.local=/mavenrepo
COPY --from=jenkinsfilerunner-mvncache /mavenrepo /mavenrepo
ADD . /jenkinsfile-runner
ADD app /jenkinsfile-runner/app
ADD bootstrap /jenkinsfile-runner/bootstrap
ADD payload /jenkinsfile-runner/payload
ADD payload-dependencies /jenkinsfile-runner/payload-dependencies
ADD setup /jenkinsfile-runner/setup
ADD vanilla-package /jenkinsfile-runner/vanilla-package
ADD pom.xml /jenkinsfile-runner/pom.xml
RUN cd /jenkinsfile-runner && mvn clean package
RUN mkdir /app && unzip /jenkinsfile-runner/vanilla-package/target/war/jenkins.war -d /app/jenkins && \
rm -rf /app/jenkins/scripts /app/jenkins/jsbundles /app/jenkins/css /app/jenkins/images /app/jenkins/help /app/jenkins/WEB-INF/detached-plugins /app/jenkins/winstone.jar /app/jenkins/WEB-INF/jenkins-cli.jar /app/jenkins/WEB-INF/lib/jna-4.5.2.jar
Expand All @@ -26,8 +32,4 @@ COPY /packaging/docker/unix/jenkinsfile-runner-launcher /app/bin
VOLUME /build
VOLUME /usr/share/jenkins/ref/casc

ENTRYPOINT ["/app/bin/jenkinsfile-runner-launcher", \
"-w", "/app/jenkins",\
"-p", "/usr/share/jenkins/ref/plugins",\
"-f", "/workspace", \
"--runWorkspace", "/build"]
ENTRYPOINT ["/app/bin/jenkinsfile-runner-launcher"]
16 changes: 15 additions & 1 deletion packaging/docker/unix/jenkinsfile-runner-launcher
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ if [ -n "$DEBUG" ] ; then
export JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 $JAVA_OPTS"
fi

. /app/bin/jenkinsfile-runner
if [ -f "/workspace/Jenkinsfile" ] ; then
JENKINSFILE_PATH="/workspace/Jenkinsfile"
elif [ -f "/workspace/Jenkinsfile.yml" ] ; then
JENKINSFILE_PATH="/workspace/Jenkinsfile.yml"
else
# Default fallback which delegates discovery to JFR
JENKINSFILE_PATH=/workspace
fi

/app/bin/jenkinsfile-runner \
--jenkins-war /app/jenkins \
--plugins /usr/share/jenkins/ref/plugins \
--file ${JENKINSFILE_PATH} \
--runWorkspace /build \
"$@"

0 comments on commit 0723e2b

Please sign in to comment.