Jenkins build and deploy separately - maven

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.

Related

maven build from different repos from one pom.xml

Is it possible to build(and not download) a dependency in same pom.xml?
Another team builds/maintains a code in git repo A. I have to use that as a library in my code.
When I build my code using maven, I want this to be checked out and built and then the jar be included as a dependency.
I understand this can be achieved using Jenkins jobs.
And in dev stage, I can install an already built jar in m2 repo and use the jar as dependency.
However, I would want to confirm if its possible to solve this scenario outside Jenkins. That is, I as a developer, can I configure the build of repo A during build my code?
I hope I am able to explain the scenario.
Thanks.

Maven versioning & repositories - How to update during build

I have a project being built with maven using TFS for source control and Octopus for deployment.
At the moment, I can perform a TFS CI build, create an octopus deploy package as a zip file from the output, and use octopus to deploy to my deployment target, extract the package and install the app.
What I would like to do is increment the version of the application projects when a new build is performed (perhaps nightly).
Is the correct way to do this, to get my build server to set the new version on the project, using mvn versions:set -DnewVersion=x.y.z then to run mvn deploy to push the updated packages to the networked repository. Then to finally create my maven package from this?
I'm a bit unsure the best way to allow my build server to up issue the versions and then use those updated versions of the packages in the build.
It seems like I may have the wrong end of the stick here. Any pointers greatly appreciated.
If you had already at Maven 3.2 or better Maven 3.3+ you could have done that in a more convenient way, but if you are at Maven 3.1. you need to go
via build-helper-maven-plugin and versions-maven-plugin you can do simply via:
mvn build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}\${parsedVersion.nextIncrementalVersion} \
versions:commit
But as far as I know the versions:commit will probably not work based on support of TFS for Maven SCM....(I never tested it with TFS). But the commit step be done by something different.

How to split maven tasks between tasks and pipelines without running redundant maven tasks

I'm trying to set up a deployment pipeline using GoCD as follows:
Compile, test and deploy to Maven repo
Check out source code from SVN
Run mvn clean compile test install
Run mvn deploy to deploy the WAR artifact to Sonatype repo
Deploy to Tomcat server
Retrieve WAR artifact from Sonatype repo
Run mvn tomcat7:redeploy to deploy it to the Tomcat instance I have running
The thing is, I can't seem to split 1.2 and 1.3 (for example) without having to rerun the whole the entire source code checkout again in 1.3. This seems redundant to me as I had already gotten it up to the package stage and should be able to just continue to run from there.
Between 1.3 and 2.2, I can see that it can retrieve the WAR artifact from Sonatype, but I can't do much with it with maven because there's just no pom.xml for me to execute the maven task with. Of course, I can just add the source code material and run the entire mvn package tomcat7:redeploy cycle again, but I'm pretty sure that's not what this was designed for initially.
I can also write a shell script and ask Go to run it to copy the WAR file to the right location, but again, I could have done everything in one maven pass and save myself some effort but that would just reduce the entire pipeline to a single box which isn't much help to help visualize the deployment pipeline.
Can I get some advice on how I should be designing this pipeline if I wanted to split a maven task flow into different Go tasks / pipelines?
Thanks
Wong

Maven deploy multi module project only if all modules build successfully

I have a maven multi module project with several modules. I want to deploy them (mvn deploy) only if they all pass a full mvn install (which includes the tests).
Currently, I run a mvn install on the project. If all modules pass, I run mvn deploy to do the deployment. The problem I see is the waste of time calling mvn twice (even if I skip tests on the second run).
Does anyone have an idea on this?
EDIT: I have learned that using Artifactory as a repository manager and the maven-artifactory-plugin with your maven setup will add the atomic deploy behaviour to the mvn deploy command. See the Build Integration section in the Artifactory documentation.
[DISCLOSURE - I'm associated with JFrog. Artifactory creator.]
Take a look at the deployAtEnd parameter of Maven Deployment plugin: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
This is a bit tricky. Maven is not atomic when it executes the build life-cycle. So a broken set of artifacts may end up in a repository.
One solution I know is Nexus Pro: http://www.sonatype.com/Products/Nexus-Professional/Features - it allows you to promote builds or define certain repos as staging. So only verified versions get promoted to be used. Maybe artifactory has something similar - I just don't know.
If that solution is too expensive you probably need to create a cleanup build or profile to remove artifacts that where already uploaded. My first guess would be to write a Maven plugin to use the the proxy remote API or maybe the maven features are already sufficient. But since deploy means update the meta-data xml files too I dont think there is a delete - not sure on this either.

Bamboo script task artifact

I am using Bamboo as a build server. We typically only build maven projects which is really easy with Bamboo.
We are now trying to build debian packages with Bamboo. I am able to build the .deb file just fine, but I would like to be able to use that deb file as an artifact for another task, such as adding it to a reprepro instance. I'm trying to separate the tasks out so I can reuse the "deploy to reprepro" task in all of my other plans.
I can't find a ton of documentation on script tasks other than very simple things. How can I do this? Or are there any plugins that I have missed that will build and deploy a deb for me? Thanks!
You should be able to find further information on Bamboo and Maven artifacts here:
https://confluence.atlassian.com/display/BAMBOO034/Configuring+Artifact+Sharing+between+Jobs

Resources