Get NOT_BUILT build result in Jenkins when building maven project with selective dependencies - maven

I have a multi-component maven project in Jenkins. This project has a Send Files over FTP Post-Build step. I have set my mvn goals to build just my desired component; not all of them:
clean install -pl component-x,component-y -P develop -X
All the dependencies in my project are built successfully;
[INFO] component-x ............................ SUCCESS [ 5.026 s]
[INFO] component-y ............................ SUCCESS [ 16.912 s]
but the Jenkins says:
FTP: Current build result is [NOT_BUILT], not going to run.
EDIT 1:
Yes, I have read this issue. People suggestions include:
Do it manually.
Use Execute Shell instead.
But there were no solution for How to do it manually.
BTW I have an FTP server which I want to put files on; it's not possible for me to use Execute Shell.

Looks like because of this bug https://issues.jenkins-ci.org/browse/JENKINS-16240
Either you can set the status to success manually or use execute shell for ftp instead of the plugin.
You can run a post build groovy script manager.buildSuccess()
See here

The problem is, that the Publish over FTP plugin checks if the build was successful. Unstable is accepted, too, but NOT_BUILT isn't. If the build is not considered successful, the plugin refuses to run.
It is arguable, if that is an expected behavior. The user might want to transfer files, even if the build was not successful. Besides, the NOT_BUILT obviously refers only to the last build step, not to the overall result which is still SUCCESS.
There is an issue filed under JENKINS-55816.
I've created a patch that does not check for the build result which can be downloaded from here (use at your own risk, with no warranty whatsoever).

Related

Skip tests in Jenkins

I've set up a build on Jenkins for a Maven project, and I would like to build it without running any of the tests. I've tried entering "clean install -DskipTests" in the goals field, like this:
But it doesn't work. What am I doing incorrectly?
Note: I want to skip the tests without touching the pom. I have a separate build that DOES run the tests.
The problem is that I omitted =true. I was able to build without running tests by entering:
clean install -DskipTests=true
Just to extend the answer, maven has 2 options for skipping tests:
-DskipTests=true — The one that was mentioned. With this parameter, maven ignores tests completely.
-Dmaven.test.skip=true — With this option maven compiles the tests but doesn't launch them.
So you may want to use the second option instead as fast code compile validation. E.G.: if you develop some library or module that will be used by some one else you must be sure that you don't brake contract with the client. Tests compilation can help you with this.
Use either of these parameters depending on your needs.
use "Goals and options" value is "clean install -DskipTests=true".
it works like a Charm. I saved hours of time using this Option. :-)
I use option "-DskipTests=true" in "Invoke top-level Maven target" -> "JVM Options" and it works fine.

Forcing authentication on Maven release

I have a problem getting Maven to release to a Nexus server. Seemingly, it refuses to use my provided username and password (but there might be other problems as well).
When I first type 'mvn release:perform', I get a'not authorized'-error. However, some files are created on the Nexus, namely a pom with checksums etc. When I try a second time (without changing anything), I get a different error: '400 bad request'
When I delete the files and try again, I get the first error once again.
I have run this with the -X flag to see if I can make any sense of what is happening, and I have discovered that the first time I run the command, maven omits my username and password provided in settings.xml:
[INFO] [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://nexus.example.com/content/repositories/releases
When I run it the second time, it includes my credentials:
[INFO] [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://nexus.example.com/content/repositories/releases/ as developers
Notice it says 'as developers'
Of course I don't know that the fact that it prints it differently actually means anything, but it seems that way.
When I allow redeploy for the releases repository in Nexus, I always get the first variant (not authorized).
If anyone can tell me how I might force Maven to use my credentials (if that is indeed what it is not doing) or on what else might be wrong, I would be very happy.
I have got it working now, by specifying in the maven release plugin that it only deploy, and not deploy and deploy site as is default.
mvn site:deploy fails with the error: Wagon protocol 'http' does not support directory copying.
Of course, my original error message did not refer very much to site at all.
Way to produce useful error messages, Maven!
I found a way to force preemptive authentication here: http://maven.apache.org/guides/mini/guide-http-settings.html (it didn't solve my problem, but it is an answer to the title.)

Which Maven goal to use as no-op (for scripting purposes)?

I have a script on Jenkins CI which optionally does dependency:go-offline. The other option should be to do nothing. But I can't put "" in there - it must be a goal.
So - which one would you pick? It should:
Be in central, always reachable
Take minimum time
Have minimal output
Have no side effects
I was thinking of some help:... goal but those tend to have a lot of output. Any better?
You can use this goal and option:
mvn --quiet help:help
the -q,--quiet option causes the output to only show errors.
Note that Jenkins allows you to add options like --quiet as diplayed in the usage: mvn [options] [<goal(s)>]. You configure these in the Jenkins job’s “Goals and options” field.
Check mvn --help output for further information.
I know this is an old question, but I came across it when I had the same requirement and it's still unanswered, so I'm posting for anyone who needs it in future.
This still depends on the current project, but could be useful if you don't want to hardcode a specific plugin for some reason:
mvn -pl ./ validate
-pl ./ means only current project, ignore submodules. Alternatively you could specify specific project by relative path or [groupId]:artifactId.
validate is the first phase of the Default Lifecycle. Doesn't change or build anything.
Alternatively, if you don't have a maven project at all, some maven plugins, or rather specific plugin goals, can be executed without it. E.g.:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:help
It would still scan projects if it sees a POM in the current directory. And of course you still need to have the plugin in your local repository.

Jenkins multi configuration passing parameters when running Maven job

I'm trying to set up a Jenkins multi configuration job for the selenium tests of my project that runs against multiple browsers. I checked the different options and the multi configuration job seems to be a good fit, but I cannot make maven pass the parameters correctly to maven.
I have a few parameters I need to pass to maven, mainly browserName and appDomain, and also a Profile to run the tests. To configure the job I do the following:
Define the SVN repository from where the code will be checked out.
Set up browserName as a user define axis, with values FIREFOX, CHROME, IE.
Create a build step of type "Invoke top-level Maven targets", and here's where I get the problems. The configuration of this part is different from other job types, usually there's a field called Goals and Options where to put everything, but in this case is divided in different fields. So I don't know where exactly put the properties and the profile.
a) The logical thing, I put the goals in Goals field and the parameters and options in the properties field, like in the image:
In this case the job runs normally without executing the tests, because the profile is not executed.
b) If I put just the profile in the Goals field, the maven call in the log is:
/opt/apache-maven-2.2.1/bin/mvn -DbrowserName=CHROME "-D-Dappdomain=0 -Dtestenv=test -Drc=true -DsuiteXmlFile=testOne.xml -U -Dapp.instance.key=jenkins -Denv=default" clean verify -Pwebtests
And the exception is:
[INFO] [enforcer:enforce {execution: enforce-property}]
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must pass the appdomain as parameter! Example: -Dappdomain=20
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must pass the test environment as parameter! Example: -Dtestenv=beta
So is not getting the properties
c) Finally, if I put everything in the goals field, I get the following exception:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'property:merge'
[0] Inside the definition for plugin 'property-maven-plugin' specify the following:
<configuration>
...
<environment>VALUE</environment>
</configuration>
-OR-
on the command line, specify: '-Denv=VALUE'
I tried with a normal and parametrized job and works perfectly...
Jenkins version is: 1454 and Maven is 2.2.1
I found out that the Jenkins machine wasn't properly configured. I tried in another instance and was all good with the following configuration:
-Goals: clean verify Pwebtests
-Paramenters: (properties file format)
appDomain=0
testenv=test
env=default
....
And as a sidenote, the other jobs were working because they were using the Jenkins Maven plugin, which seems to use java to launch a Hudson class that calls Maven, instead of calling directly the mvn command, which is what happens when a build step of type "Invoke top-level Maven Targets"

hudson for newbies: how do i run software after successful build

i'm new to world of continuous integration and software developement.
I wanted to try hudson so i installed it on my ubuntu machine and created a new job. i pointed it to an open source project's svn (keepassx) just to try.
Hudson downloaded everything from the repository and marked blue for successful build.
aren't i suppose to be able to execute the software now somehow ? i thought once it is built i can run it, but i can't find any executable in the project's home page under hudson user home dir.
thanks.
A Hudson/Jenkins build breaks down into three steps:
update source code in workspace
run build
publish build artifacts
It sounds like you've got step 1 covered.
If the project you linked to has instructions for building (ant, maven, etc.), you can enter these as build steps into the "Build" section of the project configuration.
You can then take the resulting files ("artifacts"--jar, exe, so, bin, whatever) and publish these using the "Post-build Actions", or if necessary you can grab them directly from the workspace filesystem.
Assuming the build artifact was an executable, you could then run it after downloading it from Hudson, or make a build step or post-build action which moved it into the appropriate location and ran it.
It helps to run the build locally before trying to get Hudson to handle it--then you know what the build steps are, and what the final build artifacts are.
How would jenkins/hudson know how to 'execute' some arbitrary package that you told it to download and build? It's up to you to write a program or script to run what you want to run, and then make a downstream job (for example) to do so.

Resources