1
votes

Is there a way/plugin to manipulate artifacts after build on Jenkins? Basically, from the build result page, you can click on "MANIPULATE" link or button and execute a script/command. Thank you.

1

1 Answers

0
votes

One way you could accomplish this is:

  1. Create a RESTful web service on the box running Jenkins. The endpoint would contain the logic/script that you want to execute. If you edit the artifact on the Jenkins master directly, it will get updated in the UI.
  2. Add some simple HTML to the build description to call the RESTful end point you made in #1. For example, via a link target in a button or a tag. Note, you can also update the build description dynamically for each build using a plugin like Groovy Postbuild.

UPDATE

Note that if you don't want to create a web service running on the master, you can just invoke another job via the Jenkins remote access api that does the update for you using something like Groovy Postbuild Plugin. The Groovy postbuild step runs on the Jenkins master, so you technically have access to the entire filesystem as well as the Jenkins API.

For example, you would:

  1. Create button that would start another job by hitting the url "http://myjenkinsurl/job/myjob/buildWithParameters?param1=test". Depending on your security, you might need to specify a token to kickoff jobs like this.
  2. Inside that job write a groovy script to update the artifacts via Groovy Postbuild. For example, a small groovy script like 'copy C:\\Jenkins\\jobs\\myjob\\myartifact C:\\Backup'.execute(); could be used to backup the artifact somewhere else.