Jenkins Travis-CI build fails in cli module (shade fails) - maven

I am running a custom Jenkins 2.263.4 build on Travis-CI. We need a fix with relative pathes that never made it into the Jenkins core...well for us it is mandatory.
Based on release 2.263.4 I applied the fix in core/SecretRewriter.java and core/VirtualFile.java and also changed the version name to give it branding. This worked very well in the past releases. But the last update we did was one year ago.
Now I am running into the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade (default) on project cli: Error creating shaded jar: duplicate entry: META-INF/services/io.jenkins.cli.shaded.org.apache.sshd.common.io.IoServiceFactoryFactory -> [Help 1]
I am not able to understand it at all.
Travis-CI is here: https://travis-ci.com/github/DanielWeber/jenkins
GitHub: https://github.com/DanielWeber/jenkins
I was not able to find this exact problem from somewhere else. I tried a bit with the shade config to set
<minimizeJar>false</minimizeJar>
and similar small things, but didn't really help.
My change is so small, I don't really understand what's happening.
If nothing helps, I might consider doing changes step by step then, rather than just merging the releae to our for, but hope someone sees the problem.

The issue is that the build is being execute two times based on the mvn install followed by mvn package which is defined in travis.yml file. This causes the issue.

Related

Is there any way to get a "logical stacktrace" from Gradle?

I have a Gradle build that is failing because something is going wrong in one of the build steps. This particular step is not relevant to what I'm working on, and someone else is fixing it, but I'd rather not be held up waiting on them.
I've deleted the only reference to this step as a dependency of the core build in my build.gradle file... but it's still running! I tried running with the --stacktrace option, but all that gave me was a JVM stacktrace of Gradle's internal stack at the point where things failed, which is basically useless to me.
What I'd like is some actual useful information, a "stack trace" of the dependency chain that led to this step being included in the build process. Is there any way to get Gradle to give that to me?
I am guessing you want to see the dependency of tasks that will be executed.
In that case you could help yourself with using the following plugin https://gitlab.com/barfuin/gradle-taskinfo#gradle-taskinfo.
As such a graph is not provided out of the box from Gradle itself.
Include plugin
plugins {
id 'org.barfuin.gradle.taskinfo' version '1.0.5'
}
Then execute it to show task dependency tree (replacing task name with actual one)
./gradlew tiTree your_task_name

Jenkins build step is unable to delete directory

Until recently everything worked fine with our build process in Jenkins. We got a quite big project with many modules and a complicated dependency structure.
Suddenly, the build fails with error messages like the following:
Failed to execute goal certain-plugin:109:certainEar(certainEar)
on project app: certain plugin: Can't explode ear file
'app-SNAPSHOT.ear': Error, directory can't be deleted
The maven command that gets executed in the build pipeline and results in the error message is the following:
mvn -B -U package -DskipTests
A temporary workaround is manually deleting the affected directory. Previously I had a similar problem with the deletion of an ear, there it was possible to exclude the affected ear from this build step as it was not required there. Afterwards I got the error message mentioned above.
Now I found a (kind of) final solution: Adding clean to the targets of the maven command:
mvn -B -U clean package -DskipTests
Now the building step works fine. But why the heck does this happen? Do you have any hints what could lead to this behavior? I'm quite clueless to say the least.
Somehow this could have something to do with the extraction of an ear out of our big app ear. Shortly after we finished this and merged it into our master branch those errors began to arise. As I was not involved in this work it's hard to track down what happened there exactly and what could lead to this behavior. In parallel I will investigate what the colleagues did there. Hints from you what the reasons could be will certainly help to track this down.
I found nothing similar to this error messages online that helped me in any way.
Your solution "mvn clean" indicates me that your job is executing on a jenkins workspace that contains the execution of the previous job. I would recommend to always start your job by clearing what's in the workspace. In freestyle job, under section Source Code Management you can add the behavior
Wipe out repository & force clone
in pipelines, you would use checkout step
checkout([$class: 'GitSCM',
extensions: scm.extensions + [[$class: 'WipeWorkspace']] + [[$class: 'PruneStaleBranch']],
userRemoteConfigs: [[
url: '<git_url>'
]]
])
there are other ways to clean a workspace in a pipeline like cleanWS and deleteDir. Do prefer the checkout WipeWorkspace plugin

Jenkins + Maven Manual Installation

I installed Jenkins on to 2 new machines no-problemo!
But, when attempting to integrate Maven, I am having "command not found" in my Jenkins log, yet I can run mvn no problem in the command line.
So, I thought it was a PATH issue - so I added the /bin and also the / (of the location where Maven is extracted to), yet I'm still getting the error.
I tried adding the PATH to my ~/.bash_profile as well, so my current PATH is:
$PATH:/usr/local/bin:/Users/jenkins/apache-maven-3.5.2/bin:/Users/jenkins/apache-maven-3.5.2
Still, Jenkins will not find Maven. I do NOT want to globally install Maven, as it may affect the other 5 build servers we have that are working with Maven correctly (not sure how it's working).
The issue was resolved by simply re-connecting the Jenkins Slave. Thanks for your feedback!

Groovy install HTTPBuilder now that Codehaus shutdown?

I'm a groovy n00b and trying to use http-builder, but ALL of the examples on the web just reference the same #Grab statement which doesn't work. I assume it is because codehaus.org isn't hosting groovy stuff anymore. I've tried downloading the source from github and building it with Maven, but the build fails.
How and where am I supposed to get httpbuilder for groovy?
Things I've already tried:
Deleting the grapes directory from this post didn't work.
I got this code snippet from this other post, but it doesn't work for me either.
#Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
def http = new groovyx.net.http.HTTPBuilder('http://www.codehaus.org')
println http
Here is the error in the IntelliJ console:
/Users/kenny/Sites/inadaydevelopment.com/reports/fetch_windows_appstore_report.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes --
[download failed: xerces#xercesImpl;2.9.1!xercesImpl.jar,
download failed: xml-apis#xml-apis;1.3.04!xml-apis.jar]
EDIT 1:
Tried running it from the command line, still same error message.
Tried grab artifacts in IntelliJ, but that failed too:
I wondered if it was Mac related, and bingo. I uploaded this script to my CentOS server and it ran just fine. There is something related to MacOSX+groovy that is causing the problem.
Got it! It looks like it was the maven cache that was the problem.
I found the solution on this page:
rm -rf ~/.m2/repository ~/.groovy/grapes
I had previously tried removing the ~/.groovy/grapes cache, but that didn't fix the problem. Removing the ~/.m2/repository is what actually did it for me.
This works fine from the groovy console and from the command line.
The http-builder project is hosted on Maven Central.
Grab will actually use JCenter, but JCenter mirrors Maven Central so this resolution works.
Not sure why you would have trouble resolving transitive dependencies... it may be that you are using a proxy, for example... could also be your settings for Maven or Ivy... Check the Groovy Grapes documentation to see if you might inadvertently have something configured that causes this problem.
Also, try from groovyConsole or the command-line to rule out some conflicts within IntelliJ.
From IntelliJ, point to the Grab annotation and hit Alt+Enter. Then select grab artifacts and Enter.
It should work (works for me) and you should be able to run the script without problems.
If it complains about Ivy not being in the classpath, just add Ivy to the module dependencies and it will work.

set configuration properties in sonar

Maybe, this question is silly but I'm very new. I try to search without luck.
I got two errors when building maven project with sonar:
No information about coverage per test.
Although I had test code and these testing classes cover the code.
The global property 'sonar.doxygen.deploymentPath' is not set. Set it in SONAR and run another analysis.
I dont know it should be set where in sonar server. I set in web.xml or sonar-server.properties but it does not work.
Thanks.
About the first warning message this is not an error but a warning : since Sonar 3.5 this is possible to get the code coverage relating to each unit test. Here the message just says that this feature is not activated which is expected by default. Nevertheless I do agree that this warning message can be misleading.
About the second error message, I don't know the doxygen plugin but the message seems to be pretty clear : the sonar.doxygen.deploymentPath property has not be defined. See the plugin documentation : http://docs.codehaus.org/display/SONAR/Doxygen+Plugin.
Two things:
There is no war folder anymore since the sonarqube has given up tomcat support
The doxygen plugin is not implemented to upload the files in to the sonarqube server &/ installation, which means it only can be done by referencing the path inside your installation, e.g.:
run "mvn install sonar:sonar" in your project "/root/test.example.sonar.com"
in sonarqube set the cfg-key "sonar.doxygen.deploymentPath" the value: "/root/sonarqube-4.1.1/web/" and the cfg-key "sonar.doxygen.deploymentUrl" the value: "http://:9000"
have fun with your doxygen
Remember that the plugin will only be run through your mvn cmd, refreshing the page only will not do the job, you will have to analyse again after each cfg set :/
Check the file system and folder permission

Resources