I am trying to build a maven project in Jenkins with Build Profile ID of pom.xml. But Jenkins is only building with dev profile and not catching any of other profiles. with the same pom.xml.
I've tried building on command prompt and it's working fine, I just cannot do it in Jenkins.
I am having similar issue running maven 3.3.9 from Jenkins ver. 2.138.
So far, with time consuming trial and error, I have found that Jenkins does not tolerate a space between the -P and the profile name AND it can only handle a single profile. So you should be able to get something like this to work:
mvn groupId:artifactId:goal -Pprofile-1-only
how did you set-up your Jenkins to run the command?
Profiles should b specified using the -P option:
mvn groupId:artifactId:goal -P profile-1,profile-2
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
My guess is that in your Jenkins config (build steps), you have not specified anything, or you provide the wrong profile.
Could you try and let us know?
Related
I am using SonarQube version 6.7 for running analysis of Maven projects using the command mvn clean verify sonar:sonar from the project directory using command prompt and get the results. The sonar configurations in settings.xml for maven (v3.5.3) are added respectively.
In Jenkins (version 2.161), I have installed SonarQube Scanner for Jenkins (v2.8.1) plugin. The SonarQube Server configuration is configured as below.
In the Jenkins maven project, I have configured the post steps as below.
I have checked the Prepare SonarQube Scanner environment in the Build Environment section and the Build goal is -e clean verify sonar:sonar.
My issue is, when the SonarQube analysis for a maven project is triggered through command prompt using the command mvn clean verify sonar:sonar, I am getting the results as expected. But when the Jenkins job is triggered with the configurations above for the same maven project, the results are different and incorrect. What am I missing?
P.S- In the Post-build Actions, I can see the SonarQube analysis with maven is deprecated.
Thanks in advance.
You use different scanners. First you used SonarScanner for Maven (mvn sonar:sonar). Next you used Basi SonarScanner, which requires manual configuration of all options.
The best option to sole it is always use the same scanner. You have Maven project, so you can enable Prepare SonarQube Scanner environment in Build Environment, and next execute Sonar goal $SONAR_MAVEN_GOAL in Build.
I have Jenkins instance on Openshift
I've enabled Jenkins build of my Openshift application
Here part of Jenkins shell script parts and logs what they produce :
# Sync any libraries
rsync $upstream_ssh:~/.m2/ ~/.m2/
# Build/update libs and run user pre_build and build
gear build
command above triggers such action
+ gear build
Found pom.xml... attempting to build with 'mvn -e clean package -Popenshift -DskipTests'
Apache Maven 3.0.3 (r1075437; 2011-06-20 13:22:37-0400)
Maven home: /etc/alternatives/maven-3.0
I want to customize maven options (in this case allow to run test by deleting -DskipTests part )
Further in script I tried to add some steps combining with disabling this gear build command
# Run tests here
mvn -e clean package -Popenshfit
Above run mvn clean package but doesn't update last successful artifact, and logs shows
[WARNING] The requested profile "openshfit" could not be activated because it does not exist.
I have that profile in my pom.xml so I don't know what happening
<profiles>
<profile>
<id>openshift</id>
This is doesn't working to:
mvn --global-settings $OPENSHIFT_MAVEN_MIRROR clean package -Popenshift
Probably above is some old staff (taken from https://www.openshift.com/blogs/jenkins-polyglot-persistence-part-2)
Any idea about customizing this gear build or overriding maven options on Openshift are welcome :) I can make changes directly on machines (jenkins, jenkins-build) (as far free openshift account allow me :))
Edit
Some workaround is to run
gear build and then mvn clean package so I get build run twice and all test goals are meet and war is deployed on upstream instance and additionally Cobertura reports work fine with my Jbehave tests but this is inelegant, resources consuming solution.
I found this question while "Doing my homework" with regards to another question about Maven in OpenShift -- as to how OpenShift uses the Maven profile during the build process, broadly, as towards a goal of installing a "customized" third-party .war file providing the Liferay portal, along with some 'module' customizations, in an app using the 'jbossas' cartridge.
Although my portal-gproj app doesn't use Jenkins in its build -- as I expect that it won't have a spare gear available for Jenkins, initially, of the three "free gears" available to start with. It's a scalable app, though. However, I've found a reference item, as a blog entry by Bill DeCoste such that at least mentions two configuration features about Jenkins, as with regards to customization of OpenShift Maven builds in Jenkins: http://blog-judcon.rhcloud.com/?p=16 To summarize, the article mentions, with regards to Jenkins: One "Build/Execute shell section of the Job configuration."
Though I've not used Jenkins, myself, but I've seen it in use, however -- I think it's used in the eXo Platform for instance. I assume that Jenkins would have a sort of web-based interface for job configuration? (I tend to prefer the shell/filesystem interface onto Maven, personally)
Alternately, there is the OpenShift Origin Server source code, and an OpenShift Origin System Architecture Guide corresponding, as in reference to the OpenShift Origin baseline, on which (I assume) OpenShift Online is running, in its layer on the Amazon EC2 cloud. "If all else fails, there's the source code," just like in so many things Red Hat, LOL. It seems that there are both jenkins and jenkins-client cartridges under OpenShift Origin. Certainly, the details of the process used by either of those cartridges would be apparent from its source code.
Hope this helps! Coffee cheers.
I am trying to use Jenkins and Selenium for CI with my Spring Project that I will be running in AS7.
I would like to know if I can get Jenkins to issue a "maven jboss-as:deploy" command line on my project to deploy it to my AS7 server.
Can someone please let me know if this can be done..
No need to involve Jenkins here. Just add the jboss-as:deploy plugin to your pom.xml, bound to the pre-integration-test phase of your build. Then when you run mvn install (either locally or on Jenkins), your war will be deployed to the AS7 server.
I am actually trying to develop a Jenkins plugin using maven but I am unable to test it.
I created my project with the command mvn -cpu hpi:create. I called the project jenkins-plugin-tutorial. I packaged it with mvn package or mvn install and run the Jenkins server with mvn hpi:run.
By default, there is a HelloWorlBuilder for testing purpose that should appear at the Jenkins configuration page (Jenkins Menu -> Manage Jenkins -> Configure System) or under the Build section, but it does not display.
I followed these two tutorials (here and here) step by step many times by making sure that I do not make a mistake but it still dont work.
Maybe I have made something wrong. Can somebody gives me some hint how to correct my errors.
In pom.xml, try changing parent to this:
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.454</version>
</parent>
I just did quick test with that hpi:create, and it worked for me, I got both global and job config things as expected, but I had to do that change to pom.xml, before I got it to compile.
That is, I did:
mvn hpi:create
entered groupId foo.hyde.jenkins.plugins, artifactId hello-world when prompted.
cd hello-world
mvn install failed
Edit pom.xml to change the parent
mvn install succeeded
mvn hpi:run -Djetty.port=8092 succeeded (Using that port because other Jenkins is already in default port, otherwise -D... not needed.)
Go to http://localhost:8092, check global config, create job and add the build step
And it worked for me.
I'm using Maven 2, version 2.2.1.
I finally find the answer to my questions. The problem is that I was using an old version of maven, the 2.2.1 version. So I change to the last version, 3.0.4, everything is fine now.
I'm having an issue where Maven is not passing the settings to the deploy phase when I use the release plugin. I have my settings.xml file in the same folder as my pom.xml. When I run the following command it deploys successfully to the Maven repository.
mvn deploy -s settings.xml
However when I run this command, it fails saying that it doesn't have permissions to deploy to the repository.
mvn release:perform -B -s settings.xml
Here is the error message:
[INFO] [INFO] Error deploying artifact: Failed to transfer file: http://mavenrepo/groupId/artifactId/versionId/artifactId-versionId.pom. Return code is: 401
The only thing I can think that is causing the second to fail is that the release plugin doesn't pass the settings down to the deploy phase. How do I get this to work?
I used to have the MAVEN_OPTS environment variable set to specify my settings.xml file, but since this will run on from TeamCity, that is no longer an option.
I found a bug in the codehaus Jira for this same issue here. It was fixed in maven-release-plugin 2.2.2. As soon as I changed the version number in my pom.xml, it worked fine.