jenkins m2 release deploy only one artifact - maven

using jenkins m2 release plugin automatically sends some request to maven-deploy-plugin. this enables deploy of all artifacts. How can I stop this and deploy only specific artifact?

Solved by settings in pom.xml files of parent project (disable default deploy). Because parent is transefered to child - the deploys stop on all project.
after that I found the project which contained files i needed and supplied goal deploy:deploy-file and inside pom.xlm configured the goal.
m2 release plugin can send -Darguments="..." where you can set parameters for inner build. that's where I call deploy:deploy-file.
this is answer to close question.

Related

Automated deployment of EAR project without obtain dependencies from a repository

Is it possible deploy an artifact (.ear) into a application server (AS) without obtain its dependencies from a repository?
Let's me explain: the maven project I'm trying to configure for deploy into a AS has 3 modules:
Web (.war - front end)
EJB (.ejb - back end)
Entity (.jar - entities classes)
These modules are wrapped into a EAR module and none of then are available in some repository (like Nexus or JFrog Artifactory). When I try to use Cargo Maven plugin or JBoss Deployment Maven Plugin, both notify that cannot resolve dependencies for these modules.
UPDATED (03/01/2019)
The issue is similar to that quoted in items 6 and 7 of the following link: http://webdev.jhuep.com/~jcs/ejava-javaee/coursedocs/content/html/ejb-basicex-eardeploy.html#ejb-basicex-eardeploy-testmodule
It's a workaround but worked. Instead of the project depends on an internal repository (like Nexus or JFrog Artifactory), it's possible defines a folder as a repository on the local machine using the Maven's parameter -Dmaven.repo.local. Thus, the plugin to deploy the artifact also can use this property and obtaining the others artifacts.
That is, to build the application on the current folder:
mvn -Dmaven.repo.local=. package
To deploy the application (.ear, in this case) using Cargo Maven Plugin, for example, without depending on an internal repository:
mvn -pl app-ear/ -Dmaven.repo.local=. cargo:redeploy
OBS: Using the maven.repo.local property, the folder defined as value will be fill with all dependencies of the project. In my case, it isn't a problem because this commands are been used on a continuous integration pipeline and all files and folder are discard on the final.

How to run a maven plugin without a POM in Jenkins?

I have a plugin which can run either using a pom.xml or without (depends upon the version of the artifact we're building: new versions go without a pom. Strange, I know).
I want to have that plugin run in Jenkins.
But when creating a maven project, I have to set a pom (or as a default, Jenkins suppose there is one in the base folder given).
Question: Is it possible to configure Jenkins to not use a pom when there is none?
As per my comment, you should use a Jenkins freestyle project build in this case, in order to have more flexibility and avoid the default assumptions of a Jenkins Maven build.
In such a build, you can then configure a build step executing a shell or a Windows command (depending on the Jenkins server OS).
Indeed, in the Jenkins Maven build, a pom file is always required, as mentioned in the help support of the Configuration > Build > Root Pom entry
If your workspace has the top-level pom.xml in somewhere other than the 1st module's root directory, specify the path (relative to the module root) here, such as parent/pom.xml.
If left empty, defaults to pom.xml

Set a different version to my jars at project deployment stage - Maven

I have a Maven deployment problem:
When I execute Maven deploy, Maven pushes all my jars to a remote repository under the project version which is specified in the POM files:
<version>version.x.y.z</version>
The problem is that I don't want to overwrite my previous jars every time I rebuild my project, I want to increment the version automatically every time I build as part of the building process.
(So, I don't want to use CLI tool such "Versions Maven Plugin" to change the pom files before the building process.)
I have an environment variable, $project.buildnumber, that I can use to set the project version.
Is it possible to configure maven-deploy-plugin to automatically change the version (for instance using this environment variable)?
Many thanks!!

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}

Access Maven build properties in Jenkins post-build script to retrieve deployed artifact

I've got a Maven project that Jenkins builds and deploys to a remote repository. I then need to copy the deployed .war to an external location. I've been trying to do this with a post-build shell script but I don't see any way to get the build information from maven (for example, the URL of the deployed artifact). Is there a way to get it, or a way to do this that's more integrated into maven? I can calculate the deployment path using Jenkins build parameters but it seems like a hack.
Thanks,
Steve
After a maven build you should always find the build artifact at
target/<artifactId>-<version>.<packaging>
You can access this path within the maven pom.xml by using the maven properties (see pom reference)
${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}
To copy the artifact to another location after the build you can use several approaches described e.g. in this thread.

Resources