I'm developing an extensión for Jenkins, that consists of a new WEB API aimed to provide our ALM tooling with tailored operations on Jenkins. The starting point for me was this guide, which I have reproduced step by step.
After manual tests of a bare minimum API, I concluded that the extension was working and ready for further development.
To speed up development and testing, I have also prepared a canary test in JUnit, following the previous guide (linked above) and this other to feed test with @LocalData.
The firsts times I run the JUnit, it worked. Test passed. So, I was able to run mvn clean packge and complete the build executing (and passing) all tests
Today, I did open the IDE, run the same maven goals to ensure that everything was ok (a routine of mine), but tests failed due to a 404 Not Found
Here the stacktrace
Test timeout disabled.
=== Starting test_ping(net.corp.jenkins.plugins.almapirest.AlmApiTest)
0.152 [id=1] INFO o.jvnet.hudson.test.WarExploder#explode: Picking up existing exploded jenkins.war at /home/user/Desarrollo/workspace-11/jenkins-plugins/imi-alm-jenkinsplugin-almapirest/target/jenkins-for-test
0.522 [id=1] INFO o.jvnet.hudson.test.JenkinsRule#createWebServer: Running on http://localhost:34866/jenkins/
1.057 [id=33] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization
2.433 [id=38] INFO hudson.PluginManager#considerDetachedPlugin: Loading a detached plugin as a dependency: /tmp/jenkins11162667569266280008/plugins/bouncycastle-api.jpi
2.545 [id=38] INFO hudson.PluginManager#considerDetachedPlugin: Loading a detached plugin as a dependency: /tmp/jenkins11162667569266280008/plugins/command-launcher.jpi
2.554 [id=38] INFO hudson.PluginManager#considerDetachedPlugin: Loading a detached plugin as a dependency: /tmp/jenkins11162667569266280008/plugins/jdk-tool.jpi
2.566 [id=38] INFO hudson.PluginManager#considerDetachedPlugin: Loading a detached plugin as a dependency: /tmp/jenkins11162667569266280008/plugins/jaxb.jpi
2.791 [id=38] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$2 (file:/home/user/.m2/repository/com/google/inject/guice/4.0/guice-4.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
6.538 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
6.577 [id=34] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins
6.590 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
7.742 [id=37] INFO jenkins.InitReactorRunner$1#onAttained: System config loaded
7.743 [id=37] INFO jenkins.InitReactorRunner$1#onAttained: System config adapted
7.743 [id=37] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
7.748 [id=31] INFO jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
7.858 [id=35] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
10.414 [id=1] INFO n.o.j.p.almapirest.AlmApiTest#logJenkinsWebResponse: <html><body>
<h1>404 Not Found</h1>
<p>Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request
<pre>
-> evaluate(<hudson.model.Hudson@5d1c17df> :hudson.model.Hudson,"/alm-api/ping")
-> evaluate(((StaplerProxy)<hudson.model.Hudson@5d1c17df>).getTarget(),"/alm-api/ping")
-> evaluate(<hudson.model.Hudson@5d1c17df>.getDynamic("alm-api",...),"/ping")
hudson.mo...@5d1c17df.getDynamic("alm-api",...)==null. Back tracking.
-> evaluate(((StaplerFallback)<hudson.model.Hudson@5d1c17df>).getStaplerFallback(),"/alm-api/ping")
-> evaluate(<hudson.model.AllView@2c546831[view/all/]> :hudson.model.AllView,"/alm-api/ping")
-> evaluate(<hudson.model.AllView@2c546831[view/all/]>.getDynamic("alm-api",...),"/ping")
hudson.model.AllView@2c546831[view/all/].getDynamic("alm-api",...)==null. Back tracking.
<font color=red>-> No matching rule was found on <hudson.model.AllView@2c546831[view/all/]> for "/alm-api/ping"</font>
</pre>
<p><hudson.model.AllView@2c546831[view/all/]> has the following URL mappings, in the order of preference:<ol>
<li>
If path ends without '/' insert it
<li>
When I run mvn hpi:run to do manual testing, the extension works and the endpoints are accessible. I also check that work/plugins contain my extension packaged as hpi.
I have realised that when I run JenkinsRule , a new Jenkins is downloaded and deployed in /tmp and static content is deployed in {projectDir}/target/jenkins-for-test. But my plugin is not in any of these folders. So my guess is that the failure is caused because my source code is not loaded properly during the test execution.
Does anyone know why my JUnit' no longer load and finds my extension?
It should be something related to my local environment or workspace, but I don't know what could have changed since the last time tests worked.
The test code is
Thank you in advance!
Advertiment legal: la informació d’aquest missatge de correu electrònic és confidencial i s’adreça exclusivament al destinatari previst. Si ha rebut el missatge per error, sisplau, notifiqui-ho al remitent i esborri’l sense copiar-lo, enregistrar-lo ni distribuir-lo.
Advertencia legal: la información de este mensaje de correo electrónico es confidencial y se dirige exclusivamente al destinatario previsto. Si usted ha recibido el mensaje por error, por favor, notifíquelo al remitente y bórrelo sin copiarlo, grabarlo ni distribuirlo.
Legal warning: the information contained in this e-mail message is confidential and is for the exclusive attention of the planned recipient. If you have received the message by error, please notify the sender and delete the message without copying, recording or distributing it.