How to move my own archive file from Jenkins system to artifactory - maven

Thanks in advance! I am new to Jenkins and Maven. Please clarify my query for better understanding.
After the build war getting deployed from Jenkins system to Artifactory location (created under the tags <distributionManagement>/<snapshotRepository> in parent pom.xml). How this is happening without any scripts configured in Jenkins?
Can I do the same for my own archive file to place in Artifactory from Jenkins system after the build? I exposed some jars and getting archived in Jenkins system during the build and expecting same to be placed in Artifactory after the build same as how war is getting placed in Artifactory.
PLugin details for deploy:
I have many webapps and parent/super pom.xml.All wars are getting deployed in artifactory repository.Now looking for solution to deploy common folder also (ProvidedDependencies_${version} - Created during build time) .
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>artifactory</repositoryId>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>/ProvidedDependencies_${version}</file>
</configuration>
</plugin>

Invoking mvn deploy deploys the artifact(s) that has (or have) been built during the current run to your local repository, Artifactory in your case. See Introduction to the Build Lifecycle.
A Jenkins Maven 2/3 project or a Free-style software project with an appropriate build step can be configured to invoke mvn deploy.

Related

Using maven-deploy-plugin to deploy Eclipse product

I am trying to deploy an Eclipse product to Nexus repository. I am somewhat successful, but still get some errors that I am not sure how to handle.
I am using maven-deploy-plugin in the feature (F) that builds product:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>snapshots</repositoryId>
<packaging>zip</packaging>
<generatePom>true</generatePom>
<url>http://repo:8081/nexus/content/repositories/snapshots</url>
<groupId>my.group</groupId>
<artifactId>my.artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<file>
target/products/product.zip
</file>
</configuration>
</execution>
</executions>
</plugin>
I execute 'mvn clean install' to build the product and then 'mvn deploy' on F. If I do that then I get error
Exception while publishing product /home/akravets/dev/workspaces/trunk/my.repository.feature/myProduct.product: publishing result: [Included element my.product.feature.feature.group 8.0.1.R20180301-1431 is missing. Cannot determine filter for requirement to this element.] -> [Help 1]
I've read discussions about this issue, but nothing seems relevant to my issue because I don't have any defined deploy phases besides the one in maven-deploy-plugin.
If I change phase of maven-deploy-plugin to 'install' I get almost satisfactory results. The zip file and generated pom get deployed to repository, but the build fails with error
product.qualifier-p2artifacts.xml. Return code is: 400, ReasonPhrase: Bad Request.
Why does this file even gets considered to be deployed to repository when it's not in file element of maven-deploy-plugin and it's not in the directory structure where zip file is: target/ vs target/product/product.zip? Is this because maven-deploy-plugin is executed during the install phase and it picks up all generated resources as candidates for deployment?
I simply recommend you to use Maven-Tycho to deploy Eclipse RCP product.Tycho determines the dependencies of a plug-in via the MANIFEST.MF file of the plug-in and fetches the required plugins-bundles through the online repositories.
You can check this git repository as an example; rcp - tycho

Can't find my Staging Repository

I am a newbie trying to deploy artifacts to maven central for the first time. I followed the directions to configure maven to deploy to a staging repository. The maven build reports success. When I go to look for my staging repository, I don't see it. When I search for my artifact by searching for "markgrand" the artifact is found.
The group ID is com.markgrand, so I am expecting to see a staging repository with a names that begins with "commarkgrand-", but there is none. What am I doing wrong?
It's been awhile, so I do not remember the exact detail. The problem was that I had told the maven plugin to do too much. I think i had a step in there to close the thing, which made it no longer a candidate for deployment. Here is the staging plugin XML that is working for me:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>

WSO2ESB - Building a CAR file with Maven

Using WSO2 Developer Studio (version 3.7.0), I have created a WSO2 ESB proxy service with a sequence in a "ESB Config Project", this proxy service using a wsdl file located in a "Registry Resources Project". I also created a "Composite Application Project" to generate my .car file (including proxy service, sequence and resources), and deployed this file in my WSO2 ESB installation with success.
Now I am trying to generate (then deploy) the .car file using maven command.
I first tried this solution : https://docs.wso2.com/display/DVS370/Deploying+a+CAR+File+with+the+Maven+Plug-In.
When executing command "mvn clean install" on my ESB Config Project, I get this error :
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory ([ESB Config Project Path]\target\capp).
Please verify you invoked Maven from the correct directory. -> [Help 1]
Indeed, the install goal is configured to be executed in "target/capp" directory :
<directory>target/capp</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<extensions>true</extensions>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>clean</argument>
<argument>install</argument>
<argument>-Dmaven.test.skip=${maven.test.skip}</argument>
</arguments>
</configuration>
</execution>
...
Then I tried to create a "Maven Multi Module Project", as suggested here : maven build for WSo2 artifacts, but I did not found any solution to make it work :
following the steps from this documentation (https://docs.wso2.com/display/DVS310/Using+Maven+with+Developer+Studio?src=search), I created a "Maven Multi Module Project", and selected my Config, Resources and Composite projects as children. Then I launched the "mvn clean install" command, but still getting the error on ESB Config Project (no POM in target/capp folder).
Actually, I just did not found any information about these errors, and do not understand why the WSO2 documented solution did not work for me.
Does anyone have a suggestion about that ? How does WSO2 Developer Studio generate the .car file ?
Thanks
I found another answer for this problem. The exec-maven-plugin version seems to be buggy. The WSO2 Developer Studio 3.7.0 add a buggy version (1.2) when creating the project. You just have to change the artifact from:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
to:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
See this as a complementary information:
exec-maven-plugin says cannot run specified program, even though it is on the PATH
I finally succeded in generating a .car file and creating a maven multi module project.
I was trying to create all my maven projects with WSO2 Developer Studio 3.7.0, although the sample said to use version 3.2.0. As the WSO2's maven plugins versions change, it now works fine for me, executing maven install with plugin v2.0.4.
And a maven multi module project is finally just a maven project with modules, so it is OK.

maven deploy - only upload ear file to nexus

I have a maven project with a couple of modules.
When I use the maven deploy plugin, all the modules are uploaded to my local Nexus server.
I want the deploy to only upload the ear file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
You need to use this goal: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
deploy:deploy-file is used to install a single artifact along with its pom. In that case the artifact information can be taken from an optionally specified pomFile, but can be completed/overriden using the command line.
You can find an example of it being used on the usage page.

How do I deploy the results of a tycho p2 repository build to a place on the local file system or a locally maintained p2 repository

I have a working Tycho build that produces a working p2 repository. My current work flow is to manually drag and drop the results of this build from the project's target dir to the web server that hosts the p2 repository. The results of my tycho build look normal:
${projectBaseDir}/target/repository
- features
- com.my.product.feature.201111071414.jar
- plugins
- com.my.product.plugins
- artifacts.jar
- content.jar
So, what is the "industry standard" for taking the results of this build in the repository directory and placing them on a web server.
In this case, I am running the p2 repository's web server on the same machine that is running the build sever, so a simple copy to a directory command would work.
I've tried the maven-resources-plugin using the resources:copy-resources with no luck. I kept getting an error about the invalid output directory. I don't really feel like copy-resources is the way to go here, since the general purpose of that goal is to copy files to the target directory of your maven build, and not to copy files from the target directory of a maven build.
My task seems simple, and I realize there are a lot of options to copy files, but I'm looking for the "maven way" or better yet, "the tycho way" of doing this. If such a standard exists.
thanks,
TW
You can achieve what you want with the antrun plugin. It lets you use ant tasks/targets (like copying files) to do things during a Maven build.
I expect something like the following would work for you:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>configFix</id>
<phase>package</phase>
<configuration>
<target name="configFix">
<copy file="${project.build.directory}/p2/some.file" todir="C:\My\Directory" overwrite="true">
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
There is an example of Minerva how to publish the repository.
I just finished a plugin for that: http://download.ralph-schuster.eu/eu.ralph-schuster.uploadfiles-maven-plugin/STABLE/. It provides even ways to execute commands on the repository server, e.g. in order to delete old files before or merge artifacts after the deployment.
Hope it resolves the deploy problem. :)

Resources