jenkinsci / ci.jenkins.io-runner

An emulator of ci.jenkins.io instance, packaged as a single-shot Jenkinsfile Runner
MIT License
37 stars 14 forks source link

make clean build doesn't work out of the box #67

Closed tcollignon closed 5 years ago

tcollignon commented 5 years ago

Hi @oleg-nenashev

I want to try this project, because it seem to be very helpful

I follow the guide, and run make clean build but I have a first error

$ make clean build
rm -rf tmp
java -jar .build/cwp-cli-1.5.jar \
         -configPath packager-config.yml -version 256.0-test ""
 --batch-mode          : Enables the batch mode for the build (default: false)
 --bomPath FILE        : Path to the BOM file. If defined, it will override
                         settings in Config YAML
 --environment VAL     : Environment to be used
 --installArtifacts    : If set, the final artifacts will be automatically
                         installed to the local repository (current version -
                         only WAR) (default: false)
 -configPath FILE      : Path to the configuration YAML. See the tool's README
                         for format (default: packager-config.yml)
 -demo                 : Enables demo mode with predefined config file
                         (default: false)
 -mvnSettingsFile FILE : Path to a custom Maven settings file to be used within
                         the build
 -tmpDir FILE          : Temporary directory for generated files and the output
                         WAR. Defaults to 'tmp'
 -version VAL          : Version of WAR to be set. Defaults to '1.0-SNAPSHOT'
                         (default: 256.0-test)
Exception in thread "main" java.io.IOException: Failed to read command-line arguments
    at io.jenkins.tools.warpackager.cli.Main.main(Main.java:26)
Caused by: org.kohsuke.args4j.CmdLineException: No argument is allowed: 
    at org.kohsuke.args4j.CmdLineParser.parseArgument(CmdLineParser.java:509)
    at io.jenkins.tools.warpackager.cli.Main.main(Main.java:23)
make: *** [build] Error 1

To fix this I have delete _${CWPOPTS} part of the build section in Makefile

So next I have the following error, but this time I can't fix it :

Exception in thread "main" java.io.IOException: CasC section is declared, but CasC plugin is not declared in the plugins list
    at io.jenkins.tools.warpackager.lib.impl.Builder.verifyConfig(Builder.java:66)
    at io.jenkins.tools.warpackager.lib.impl.Builder.build(Builder.java:97)
    at io.jenkins.tools.warpackager.cli.Main.main(Main.java:56)
make: *** [build] Error 1

I put the full trace if needed build.txt

Do you know why ?

Thx you

oleg-nenashev commented 5 years ago

Hmm... likely it is a glitch after the Custom WAR Packager update. I have also seen it few times on my Windows machine while building in WSL

oleg-nenashev commented 5 years ago

So this is an issue with the cache:

INFO: Checking /home/onenashev/.m2/repository/io/jenkins/configuration-as-code/1.8/configuration-as-code-1.8.hpi
Mar 20, 2019 10:31:13 PM io.jenkins.tools.warpackager.lib.util.MavenHelper artifactExists
INFO: Dependency io.jenkins:configuration-as-code:1.8 was found in the non-HPI cache.  Delete /home/onenashev/.m2/cwp_non_hpi_cache/io/jenkins/configuration-as-code/1.8/configuration-as-code-1.8.hpi to attempt another resolution attempt.
Mar 20, 2019 10:31:13 PM io.jenkins.tools.warpackager.lib.config.Config processMavenDep
INFO: Skipping dependency, not an HPI file: io.jenkins:configuration-as-code:1.8

The cache is corrupted though https://repo.jenkins-ci.org/webapp/#/artifacts/browse/tree/General/releases/io/jenkins/configuration-as-code/1.8 looks OK

If I wipe the cache and re-run resolution, I get...

Mar 20, 2019 10:36:13 PM io.jenkins.tools.warpackager.lib.util.MavenHelper artifactExistsInLocalCache
INFO: Checking /home/onenashev/.m2/repository/io/jenkins/configuration-as-code/1.8/configuration-as-code-1.8.hpi
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Failure to find io.jenkins:configuration-as-code:hpi:1.8 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR]     mvn install:install-file -DgroupId=io.jenkins -DartifactId=configuration-as-code -Dversion=1.8 -Dpackaging=hpi -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR]     mvn deploy:deploy-file -DgroupId=io.jenkins -DartifactId=configuration-as-code -Dversion=1.8 -Dpackaging=hpi -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR]
[ERROR]   io.jenkins:configuration-as-code:hpi:1.8
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR]   central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
oleg-nenashev commented 5 years ago

AFAICT, the entire cache operation pulls from a wrong repo, looks like a CWP bug. A resolution would be to wipe the entire MAVEN_HOME/cwp_non_hpi_cache repo and to rerun the build locally using a settings.xml with properly defined Maven repositories.

In my case it happens, because the default settings.xml file contains references to repositories without authentication for WSL on Windows

oleg-nenashev commented 5 years ago

Created #68 for a fix inside this repo, https://issues.jenkins-ci.org/browse/JENKINS-56652 was created for the root cause bug

tcollignon commented 5 years ago

Hi @oleg-nenashev

Thx for that ! I will try this

tcollignon commented 5 years ago

Thx you, now it works with Java 8 (and indeed it need change maven settings with https://wiki.jenkins.io/display/JENKINS/Plugin+tutorial) For information : It doesn't work with Java 11


[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Jenkinsfile Runner 256.0-1.0-beta-7-544bc7e2959c47649a74b0dad69f12df154aa1b6-SNAPSHOT SUCCESS [  6.617 s]
[INFO] bootstrap .......................................... FAILURE [  2.208 s]
[INFO] setup .............................................. SKIPPED
[INFO] payload-dependencies ............................... SKIPPED
[INFO] payload ............................................ SKIPPED
[INFO] jenkinsfile-runner ................................. SKIPPED
[INFO] tests 256.0-1.0-beta-7-544bc7e2959c47649a74b0dad69f12df154aa1b6-SNAPSHOT SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.284 s
[INFO] Finished at: 2019-03-21T11:10:06+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.2:compile (default-compile) on project bootstrap: Compilation failure: Compilation failure: 
[ERROR] /Users/tcollignon/eclipse-workspace/ci.jenkins.io-runner/tmp/build/jenkinsfile-runner/bootstrap/src/main/java/io/jenkins/jenkinsfile/runner/bootstrap/Bootstrap.java:[9,24] cannot find symbol
[ERROR]   symbol:   class PostConstruct
[ERROR]   location: package javax.annotation
[ERROR] /Users/tcollignon/eclipse-workspace/ci.jenkins.io-runner/tmp/build/jenkinsfile-runner/bootstrap/src/main/java/io/jenkins/jenkinsfile/runner/bootstrap/Bootstrap.java:[100,6] cannot find symbol
[ERROR]   symbol:   class PostConstruct
[ERROR]   location: class io.jenkins.jenkinsfile.runner.bootstrap.Bootstrap
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :bootstrap
Exception in thread "main" java.io.IOException: Command failed with exit code 1: mvn -s /Users/tcollignon/.m2/settings.xml clean install -DskipTests -Dfindbugs.skip=true -Denforcer.skip=true -Djenkins.version=2.164.1
    at io.jenkins.tools.warpackager.lib.util.SystemCommandHelper.processFor(SystemCommandHelper.java:39)
    at io.jenkins.tools.warpackager.lib.util.MavenHelper.run(MavenHelper.java:66)
    at io.jenkins.tools.warpackager.lib.util.MavenHelper.run(MavenHelper.java:46)
    at io.jenkins.tools.warpackager.lib.impl.Builder.buildIfNeeded(Builder.java:342)
    at io.jenkins.tools.warpackager.lib.impl.Builder.build(Builder.java:193)
    at io.jenkins.tools.warpackager.cli.Main.main(Main.java:56)
make: *** [build] Error 1
oleg-nenashev commented 5 years ago

I doubt it has been ever tested for building with JDK11. This package indeed runs well with JDK11, but we do not build Jenkinsfile Runner with Java 11 so far. There is ongoing effort to support building with Java 11 in the tooling, so it might be handled. Could you please report a ticket in https://issues.jenkins-ci.org/secure/Dashboard.jspa for jenkinsfile-runner?

CC @varyvol @fcojfernandez

tcollignon commented 5 years ago

Ok, I create this : https://issues.jenkins-ci.org/browse/JENKINS-56657

Tell me if it miss something in it

Thx for your work