Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66709

Archive artifacts in console script in jenkins

XMLWordPrintable

      Hi,

      I am trying to archive artifacts or add artifacts to a running build of a job in jenkins from the script console. I was able to add action and change them like this: 

      def param = Hudson.getInstance().getItem("job").getBuild("28").getAction(hudson.model.CauseAction)
      Hudson.getInstance().getItem("job").getLastBuild().actions.add(param)

      but when trying to do :

      def param = Hudson.getInstance().getItem("job").getBuild("28").getArtifacts(hudson.model.CauseAction)
      Hudson.getInstance().getItem("job").getLastBuild().artifacts.add(param)

      It returns : Results: True but nothing changed in the http://localhost:8080/job/job/32/api/xml. I also tried:

      Hudson.getInstance().getItem("job").getLastBuild().getArtifactManager().archive(ws,launcher,listener,files)

      But every time it throws some sort of an exception(I didn't know how to get the parameters(ws,launcher,listener,files) correctly)

      The whole purpose of this is to archive artifacts from a java program that runs this script on the jenkins instance. These examples are the first steps towards achieveing this goal.

      Could you please help!

      Thank you in advance

            vjuranek vjuranek
            mmakni Makni
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: