Running both default and production profile during release - maven

My build is as follows:
The first is the normal build (mvn clean install)
The other is a profile activated by property (mvn clean install -Dbuild=prod)
The first deploys to Nexus.
The second profile deploys to a production server.
How can I run both builds during the Maven release cycle.

I would separate the nexus-deploy out to a different profile and use multiple target execution:
Create a different profile to cater for the normal build and execute both targets on the build server like so:
mvn clean install -Dbuild=prod -Pdeploy

mabe Cargo can to do this. look Appfuse for example, it use mvn jetty:run-war to deploy in jetty and mvn cargo:start start to deploy to tomcat

Related

What is the difference between deploying an artifact into Artifactory with 'mvn deploy' command and with Artifactory UI?

I usually use mvn versions:use-latest-versions command to update my dependencies to the latest ones which other teams have been deployed to our free Jfrog's Artifactory server on our local address : http://192.168.100.243:8082/artifactory/X_Douran/.
My problem is when I deploy an artifact (a jar file) with Artifactory UI or with curl (using Jfrog's Rest Api), the command mvn versions:use-latest-versions doesn't work correctly and do not update my pom but when I run mvn clean deploy on my source code of my dependent project then running mvn versions:use-latest-versions on my final project it works correctly and do update my dependency in my pom.
So I want to know what is the different between deploying via Artifactory UI and deploying via mvn clean deploy ?
You always need to deploy the POM along the JAR, otherwise Maven will not work correctly with these dependencies. Furthermore, you need to make sure that the metadata files are updated. I am not sure that Artifactory does this if you deploy using curl or the UI.
Deploying your own JARs regularly through the UI is not recommended. You should build them on a build server (like Jenkins) and then automatically deploy them to Artifactory.
Changing JAR files "by hand" should be forbidden.

Jenkins build and deploy separately

I need help in configuring a jenkins job. I am able to deploy the code using mule mvn deploy command in a single job. Now i need to build the package and use the package to deploy it to multiple environments with out building it again. Can some one help me with that. I am able to package the code using mvn package. BUt when I want to deploy the build package I am using mvn deploy command and this is compiling and building the code. Am I missing something?
Usually, you would build the project and then deploy it to one Nexus/Artifactory. If you need it in different artifact repositories, you usually proxy the original repository in the other repository.
If you really need to deploy the same file to two Nexus/Artifactory, you can add additional deployments using the goals in the deploy plugin.

How Do I Properly Deploy With An Integration Test Project?

My projects are structured as:
root
common
client
server
test
server and client depend on common. test is a project that contains integration tests and these tests depend on client common and server.
If I add all of these as modules to root, then when I execute mvn deploy on root it will deploy the jars, and then run the integration tests. I only want to hit the deploy phase if my integration tests run successfully.
Is this possible with Maven?
You shouldn't run mvn deploy directly but use the release plugin instead. You have to run
mvn release:prepare release:perform
for doing and deplying a relase. See also this blog post about deploying snapshots.

Build Pipeline with Jenkins - M2 Release -> Deployment to JBoss AS

I am using Jenkins as CI environment and I want to have the ability to deploy the build artifacts directly to a JBoss AS 7.1.1 server. For releasing the Maven artifacts I am using the Jenkins M2 Release Plugin.
The project structure of the project which makes problems looks as follows:
artifact-parent-pom
webapp-module
theme-module
The maven goal jboss-as:deploy can only be called on webapp-module.
To deploy the webapp-module to the JBoss server on every build, I added a post-build step calling
mvn jboss-as:deploy
on the sub-module. This works perfectly for standard SNAPSHOT builds, but not for release builds.
When using the Jenkins M2 Release Plugin to release a new artifact version, the version number is already updated to the next SNAPSHOT-version when the post-build step is executed. I tried to deploy the release version directly at the release step, but this doesn't work, hence the goal jboss-as:deploy cannot be called on the parent-pom.
All Jeknins plugins i have found only support older versions of JBoss like
Deploy to container Plugin
JBoss Management Plugin
Is there an easy way to get this working?
I have found a workaround. I made two configurations, one for the SNAPSHOTS and one for the RELEASE builds. At the RELEASE build I added two post-steps both calling the goal version:set on the parent-pom but with different properties. This results in the following post-steps:
mvn newVersion=${MVN_RELEASE_VERSION}
mvn jboss-as:deploy
mvn newVersion=${MVN_DEV_VERSION}

deploy to repository prebuild artifacts Maven

I have run mvn install on my project then at the end I wanted to run mvn deploy -P profile1 to deploy selective modules from the project.
The issue is that mvn deploy performs build all over again when I just want to deploy the artifacts that were already compiled.
How do I do that?

Resources