jenkinsci / jenkinsfile-runner

A command line tool to run Jenkinsfile as a function
MIT License
1.14k stars 296 forks source link

option '--file' (<jenkinsfile>) should be specified only once #479

Open shadycuz opened 3 years ago

shadycuz commented 3 years ago

Dockerfile:

FROM jenkins/jenkinsfile-runner

COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
COPY init_scripts/* /usr/share/jenkins/ref/init.groovy.d/

ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/casc/casc.yaml

result:

docker run --rm -v /home/shadycuz/repos/dsty/jenkins-std-lib/:/var/jenkins_home/pipeline-library -v /home/shadycuz/repos/dsty/jenkins-std-lib/jobs/:/workspace myrunner -f /workspace/test-dev
option '--file' (<jenkinsfile>) should be specified only once

DockerFile with entrypoint from ci.runner:

FROM jenkins/jenkinsfile-runner

COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
COPY init_scripts/* /usr/share/jenkins/ref/init.groovy.d/

ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/casc/casc.yaml

ENTRYPOINT ["/app/bin/jenkinsfile-runner",\
            "-w", "/app/jenkins",\
            "-p", "/usr/share/jenkins/ref/plugins",\
            "-f", "/workspace/Jenkinsfile"]

result:

docker run --rm -v /home/shadycuz/repos/dsty/jenkins-std-lib/:/var/jenkins_home/pipeline-library -v /home/shadycuz/repos/dsty/jenkins-std-lib/jobs/:/workspace myrunner -f /workspace/test-dev
option '--file' (<jenkinsfile>) should be specified only once

Dockerfile with entry point from this repo:

FROM jenkins/jenkinsfile-runner

COPY jenkins.yaml /usr/share/jenkins/ref/jenkins.yaml
COPY init_scripts/* /usr/share/jenkins/ref/init.groovy.d/

ENV CASC_JENKINS_CONFIG /usr/share/jenkins/ref/casc/casc.yaml

ENTRYPOINT ["/app/bin/jenkinsfile-runner-launcher"]

result:

docker run --rm -v /home/shadycuz/repos/dsty/jenkins-std-lib/:/var/jenkins_home/pipeline-library -v /home/shadycuz/repos/dsty/jenkins-std-lib/jobs/:/workspace myrunner -f /workspace/test-dev
option '--file' (<jenkinsfile>) should be specified only once

Manual entry point:

docker run --rm -v /home/shadycuz/repos/dsty/jenkins-std-lib/:/var/jenkins_home/pipeline-library -v /home/shadycuz/repos/dsty/jenkins-std-lib/jobs/:/workspace --entrypoint /app/bin/jenkinsfile-runner myrunner -f /workspace/test-dev
No explicit version has been selected, using latest LTS
Running pipeline on jenkins 2.277.1
Downloading jenkins 2.277.1...
Exploding,/root/.jenkinsfile-runner/war/2.277.1/jenkins-war-2.277.1.warthis might take some time.
java.lang.RuntimeException: Unhandled exception
        at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.call(JenkinsLauncherCommand.java:59)
        at io.jenkins.jenkinsfile.runner.bootstrap.Bootstrap.call(Bootstrap.java:70)
        at io.jenkins.jenkinsfile.runner.bootstrap.Bootstrap.call(Bootstrap.java:21)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
        at picocli.CommandLine.access$1200(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
        at picocli.CommandLine.execute(CommandLine.java:2058)
        at io.jenkins.jenkinsfile.runner.bootstrap.Bootstrap.main(Bootstrap.java:45)
Caused by: java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.jar.JarFile.<init>(JarFile.java:166)
        at java.util.jar.JarFile.<init>(JarFile.java:130)
        at io.jenkins.jenkinsfile.runner.bootstrap.Util.explodeWar(Util.java:60)
        at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.postConstruct(JenkinsLauncherCommand.java:91)
        at io.jenkins.jenkinsfile.runner.bootstrap.commands.RunJenkinsfileCommand.postConstruct(RunJenkinsfileCommand.java:77)
        at io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand.call(JenkinsLauncherCommand.java:56)
        ... 10 more
shadycuz commented 3 years ago

also errors if I set --entrypoint /app/bin/jenkinsfile-runner-launcher myrunner Same error, cant use -f twice.