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

copy artifacts from last stable build of a parameterized job, by parameter

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • copyartifact-plugin
    • None

      I'd like to be able to copy artifacts from the last stable build of a job that was run with a given set of parameters. That is, for JOB1 with parameters PARAM1 and PARAM2, I'd like to be able to tell JOB2 to copy artifacts from the last build of JOB1 that had PARAM1=Bob,PARAM2=Alice. The existing syntax for specifying matrix jobs might be reusable, thus:

      Project Name: JOB1/PARAM1=Bob,PARAM2=Alice

      Bonus points for parameter expansion, so that JOB2's parameters could be used to make the selection:

      Project Name: JOB1/PARAM1=$THISPARAM,PARAM2=$THATPARAM

          [JENKINS-8657] copy artifacts from last stable build of a parameterized job, by parameter

          Alan Harder added a comment -

          I like the idea of specifying the parameters in the same way as a matrix configuration, but it seems too hacky to code that way.. I'd need a fake "job" to pass to the BuildSelector API that only returns builds with matching parameters. But then you could pick any of the available selector types..

          Much easier would be to add a new BuildSelector for this.. so you'd just put the job name in the first box, then choose "parameterized build" or something in the selector list.. this would give you a textbox to enter the param1=value1&param2=value2 bit.. but then this selector needs to know which build that matches those parameters to pick. Probably here I'd just go by status, stable/unstable. Does this sound ok?

          Alan Harder added a comment - I like the idea of specifying the parameters in the same way as a matrix configuration, but it seems too hacky to code that way.. I'd need a fake "job" to pass to the BuildSelector API that only returns builds with matching parameters. But then you could pick any of the available selector types.. Much easier would be to add a new BuildSelector for this.. so you'd just put the job name in the first box, then choose "parameterized build" or something in the selector list.. this would give you a textbox to enter the param1=value1&param2=value2 bit.. but then this selector needs to know which build that matches those parameters to pick. Probably here I'd just go by status, stable/unstable. Does this sound ok?

          evilchili added a comment -

          I like the idea of being able to specify parameters and build
          selectors both – so that I could, eg., say "copy artifacts from the
          most recent successful build of of job1 where param1=val1 and
          param2=val2" on one build, and on the next one say "copy artifacts
          from the latest saved build of job1 where ..." but I realize this
          quickly becomes a complicated set of conditions to resolve. It might
          be enough to simply have two new options in the selector list:

          • latest build (parameterized job)
          • latest stable build (parameterized job)

          For my purposes just the latest stable build would be enough, as a
          failed build implies the artifacts I would need weren't generated
          correctly anyway. But I can envision scenarios where you might want
          to copy artifacts regardless of build status.

          evilchili added a comment - I like the idea of being able to specify parameters and build selectors both – so that I could, eg., say "copy artifacts from the most recent successful build of of job1 where param1=val1 and param2=val2" on one build, and on the next one say "copy artifacts from the latest saved build of job1 where ..." but I realize this quickly becomes a complicated set of conditions to resolve. It might be enough to simply have two new options in the selector list: latest build (parameterized job) latest stable build (parameterized job) For my purposes just the latest stable build would be enough, as a failed build implies the artifacts I would need weren't generated correctly anyway. But I can envision scenarios where you might want to copy artifacts regardless of build status.

          Alan Harder added a comment -

          OK, I have an idea.. I think I can extend the BuildSelector API to make this possible.. it can be mostly-backwards compatible in that any existing impls out there will still work when not using this new feature.. all impls will need a small update to work with this specify-parameters feature. I haven't heard of any impls beside those included in the plugin and my own in promoted-builds-simple, so realistically I think everything can be updated to work right away.

          Alan Harder added a comment - OK, I have an idea.. I think I can extend the BuildSelector API to make this possible.. it can be mostly-backwards compatible in that any existing impls out there will still work when not using this new feature.. all impls will need a small update to work with this specify-parameters feature. I haven't heard of any impls beside those included in the plugin and my own in promoted-builds-simple, so realistically I think everything can be updated to work right away.

          Alan Harder added a comment -

          I did the API rework.. it will now be possible to implement this via jobname/param1=value1&... in the project name box.

          Alan Harder added a comment - I did the API rework.. it will now be possible to implement this via jobname/param1=value1&... in the project name box.

          Josh Davidson added a comment -

          I'm having some trouble with this feature on v1.21 of the copy artifact plugin. I have a related job that has two build parameters: SIM_COMMON_REV and SIM_INTERFACE_REV. The name of the job is sim-interfaces-linux64. When I attempt to "copy artifacts" by providing both parameters in the project name text box like so: sim-interfaces-linux64/SIM_COMMON_REV=${SIM_COMMON_REV}&SIM_INTERFACE_REV=${SIM_INTERFACE_REV}

          I receive the following build error: Unable to find a build for artifact copy from: sim-interfaces-linux64/SIM_COMMON_REV=default&SIM_INTERFACE_REV=default

          However, those values are completely valid, and I have a number of builds that satisfy those conditions. If I only specify a single parameter (striking the ampersand obviously) each works on it's own. It's only when combined that it has problems.

          Perhaps my syntax is incorrect, otherwise I think there is probably an issue.

          Josh Davidson added a comment - I'm having some trouble with this feature on v1.21 of the copy artifact plugin. I have a related job that has two build parameters: SIM_COMMON_REV and SIM_INTERFACE_REV. The name of the job is sim-interfaces-linux64. When I attempt to "copy artifacts" by providing both parameters in the project name text box like so: sim-interfaces-linux64/SIM_COMMON_REV=${SIM_COMMON_REV}&SIM_INTERFACE_REV=${SIM_INTERFACE_REV} I receive the following build error: Unable to find a build for artifact copy from: sim-interfaces-linux64/SIM_COMMON_REV=default&SIM_INTERFACE_REV=default However, those values are completely valid, and I have a number of builds that satisfy those conditions. If I only specify a single parameter (striking the ampersand obviously) each works on it's own. It's only when combined that it has problems. Perhaps my syntax is incorrect, otherwise I think there is probably an issue.

          Josh Davidson added a comment -

          My syntax was indeed incorrect. The following comments: https://issues.jenkins-ci.org/browse/JENKINS-8657?focusedCommentId=145502&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-145502

          seems to indicate that the parameters need to be separated by ampersands. It turns out it's commas (as stated in the help).

          Josh Davidson added a comment - My syntax was indeed incorrect. The following comments: https://issues.jenkins-ci.org/browse/JENKINS-8657?focusedCommentId=145502&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-145502 seems to indicate that the parameters need to be separated by ampersands. It turns out it's commas (as stated in the help).

            mindless Alan Harder
            evilchili evilchili
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: