0

My team has code being built and tested in Jenkins and when the build process is done Jenkins produces a SNAPSHOT.jar file. I need to unpacked the snapshot.jar file and send the extracted files and folders to a network drive. What is the best way to do that?

I've tried a few Jenkins plugins, the most recent being artifactDeployer, but when the plugins deploy the artifacts, as a post-build action, they don't unpack the jar files; I would have to execute a windows batch command after they are deployed to unpack them but I cant because the plugin runs as a "post-build action" and the batch commands are done before the post-build actions. Is there a way to deploy the artifacts and unpack them without using a plugin? Or is there a plugin that will do both? What is the best way to achieve this?

  • Simple do a Samba mount to your build system which mounts the appropriate network drive / path and than you can copy it to that area.... – khmarbaise Jan 30 '17 at 22:32
  • Can a Samba mount extract files out the snapshot.jar before sending them? – EXC3ll3NTrhyTHM Feb 03 '17 at 16:45
  • You don't understand what a samba mount is...It can't do something with a jar...You can write a script what does such things... – khmarbaise Feb 03 '17 at 17:46
  • I do not know what a samba mount is but at least in this case it sounds like it only copies the snapshot.jar file to my location. I need to unpack the snapshot.jar and send the extracted files to my location. I edited my question for clarification. – EXC3ll3NTrhyTHM Feb 03 '17 at 18:17

1 Answers1

0

The way I accomplished this was by using 7zip in a Windows batch command as a post-step in the jenkins project configuration.

The command is:

`7z x %WORKSPACE%\target\*.jar -oX:\"mapped network drive location" -y`

This extracts the artifacts out of the snapshot.jar file and places those artifacts into the network drive. I needed the files contained in the snapshot.jar to be sent to the network drive when the build completed. I am new to jenkins and the plugins I tried were post-build actions and only copied the snapshot.jar to a given location; they did not extract the artifacts out of the jar file. That is why I chose this route.