I'm using the Maven plugin was6-maven-plugin to deploy to websphere. When installing an application, there's a configuration value named "updateExisting" that should be false if I am installing a new application, and true if I am updating an existing application. I don't like having to manually toggle this value if I am fresh-installing/updating the application.
The way I see it, I can either add an uninstallApp goal to always uninstall the application before installing it, but this seems a rather silly way to do it.
I've noticed that this plugin also has a goal wsListApps that outputs all applications installed on the server. The output looks like this:
[INFO] [wsadmin] WASX7209I: Connected to process "server1" on node 1234Node02 using SOAP connector; The type of process is: UnManagedProcess
[INFO] [wsadmin] DefaultApplication
[INFO] [wsadmin] IBMUTC
[INFO] [wsadmin] MyApplicationEAR
[INFO] [wsadmin] ivtApp
[INFO] [wsadmin] query
Is it possible for Maven to scan this output for the string "MyApplicationEAR" and set "updateExisting" to "true" if it is found, and leave it "false" otherwise?
What you need is to be able to update a maven property during the life-cycle, before the phase binded with your was6-maven-plugin. (and using this property as a value for <updateExisting>)
Unfortunately, maven properties are static and cannot be changed at runtime. So at first sight it's impossible to do.
But, there is a plugin : properties-maven-plugin you can use to define new properties at runtime. The value of the property can be defined by a groovy script. Now the question is more about how can you write a groovy script telling if your app is already there or not.
Honestly, I don't know if it's a good idea to use it. I think running the uninstall goal everytime with failOnError set to false is probably the simplest way (and so probably the best, but maybe I am missing something ?)
Related
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).
Following Jenkins documentation jenkins docs
I can use the POM_VERSION environment variable to take the current version from the pom file.
But for some reason the POM_VERSION environment variable is not being refreshed from build to build. for example:
I changed the version number manually but the build number that exported was the last from the previous build.
From my python script:
print 'Current version is ' + os.environ['POM_VERSION']
which gives the following log Current version is 0.1.5 which is clearly wrong because i changed it. you can further see it in my maven versions goal output:
[INFO]
[INFO] --- versions-maven-plugin:2.1:set (default-cli) # ep-reporter ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /var/lib/jenkins/jobs/exchange-planner- reporter/workspace
[INFO] Processing com.exelate:ep-reporter
[INFO] Updating project com.company:ep-reporter
[INFO] from version 0.1.8 to 0.1.6
Props: {project.version=0.1.6, project.artifactId=ep-reporter, project.groupId=com.company}
note that it went from 0.1.5 because i have a script that advances it. but maven clearly states that its changing it from 0.1.8 to 0.1.6 which is not what POM_VERSION says
Thanks.
That environment variable is set at the time Jenkins first reads your POM file. You are clearly changing it during the build.
If you are changing it during the build, you know what you are changing to, and you should use the same mechanism to display it later.
I had the same problem and I resolved it by setting "Check-out Strategy" option to "Always checkout a fresh copy" in Source Code Management section.
I'm trying to deploy a Mule application to Standalone using Maven, but Maven is unable to move my app to the relevant apps folder and I'm given the following warning:
[WARNING] MULE_HOME is not set, not copying <app-name>
However, MULE_HOME is set, and a simple echo $MULE_HOME in Terminal gives the following, which is correct:
/opt/mule
Is there a known fix to this? Currently having to manually copy to the apps directory.
Ok, I've figured out where the issue was here. My standalone instance of Mule is in a directory /opt/mule-standalone-3.4.0 with an alias /opt/mule pointing to the same location. For some reason, Maven didn't like MULE_HOME being set to the alias. When amended to point to the actual directory, all worked fine.
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.)
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"