amphibient
amphibient

Reputation: 31368

Deploying Jenkins Artifact Built by Another Job

I installed the Deploy Plugin on my Jenkins in order to automate the deployment of my Maven built war packages to Tomcat 7. The problem is that I am able to use the plugin to deploy to a remote Tomcat server only if they are made within the same job that uses the deploy plugin. In other words, I have not been able to set up a standalone job that deploys artifacts made by a different job.

For example, I have a job named pack.foo. It uses the source code in /var/lib/project/module to create module.war and put it in /var/lib/project/module/target. However, because of the Maven version setup, the artifact posted on pack.foo's artifact page is something like module-2.0.0-SNAPSHOT.war.

The only way I am able to deploy module.war is if I add a Post-build Action to pack.foo and specify **/module.war to be a remote Tomcat manager URL (provided I have the manager's credentials in Jenkins config). Then the job's console output logs that /var/lib/project/module/target/module.war was deployed to that URL:

Deploying /var/lib/project/module/target/module.war to container Tomcat 7.x Remote with context 
  [/var/lib/project/module/target/module.war] is not deployed. Doing a fresh deployment.
  Deploying [/var/lib/project/module/target/module.war]

How can I use this, or another plugin, to deploy a WAR artifact that was made in a separate Jenkins job? I would like to have separate jobs for artifact creation and deployment. The plugin wasn't finding **/module-2.0.0-SNAPSHOT.war or even **/module.war built by another job even though there was definitely a file on disk that matched that pattern.

Upvotes: 2

Views: 2325

Answers (1)

Gerold Broser
Gerold Broser

Reputation: 14792

See the paragraph on the Deploy Plugin's page you linked:

How to rollback or redeploy a previous build

There may be several ways to accomplish this, but here is one suggested method:

  1. Install the Copy Artifact Plugin
  2. Create a new job that you will trigger manually only when needed
  3. Configure this job with a build parameter of type "Build selector for Copy Artifact", and a copy artifact build step using "Specified by build parameter" to select the build.
  4. Add a post-build action to deploy the artifact that was copied from the other job

Now when you trigger this job you can enter the build number (or use any other available selector) to select which build to redeploy. Thanks to Helge Taubert for this idea.

Upvotes: 2

Related Questions