0

I have two Jenkins tasks, one that builds and promotes the successful build, and another task that deploys those promoted builds. I'm using two plugins to accomplish this task, Copy Artifact Plugin and promoted builds.

The job that I have to build the code is a very standard one, I go to the git repository every minute to check for any changes, and if there are any changes I just Invoque Gradle Script on the Build step and select Use Gradle Wrapper box and everything builds without a problem. The only custom part of this build task is that I'm using promoted builds plugin, which works great and have a very standard configuration as well.

Build Configuration

I'm happy with my Build task, but I have a problem with my Deploy task. In my deploy task I want to select which promoted build I want to deploy, but I can't deploy the selected promoted build.

In my Deploy task I tick the This project is parameterised box and I selected the Promoted Build Parameter.

Promoted Build Parameter Configuration

The configuration looks ok, when I run the Deploy task I can select which build I want to deploy.

Select build to be deployed

The problem that I have is when I select Copy artifacts from another project. In Which build I select Specified by a build parameter and for the Parameter Name I selected the same name I gave to the Promoted Build Parameter

Copy artifacts from another project Configuration

But when I run this Deploy task I get this error: ERROR: Unable to find a build for artifact copy from: Aurora.

BUT if I change the Which build part to Copy from WORKSPACE of latest completed build everything works fine.

Working Configuration

What am I doing wrong in this configuration?

cunhaf
  • 1,057
  • 1
  • 8
  • 12
  • In order to help with your questions, It would be very helpful if you create a docker image with your jenkins tasks (with examples of course). Your question is something extensive and has a lot of configurations. Check this link with preconfigured jenkins tasks : https://gist.github.com/jrichardsz/9ebc80d18b9d40c959708c2582d47452 – JRichardsz Oct 09 '18 at 16:28
  • I tried to do the exact same thing as these guys [link](https://stackoverflow.com/questions/37486244/how-to-pass-build-artifact-into-another-job-in-jenkins), just to make sure I was able to reproduce the exact same thing, but is still returning the same error `ERROR: Unable to find a build for artifact copy from:...`. Maybe I'm missing some configuration. – cunhaf Oct 10 '18 at 09:17

1 Answers1

0

I was able to solve this problem, I don't think it was the cleanest way of doing it but at the end it worked. In the Build task I left everything as it was, I only added a Post-Build Action to Archive the artifacts.

Post Build Action

In the Deploy task I needed to change a bit more stuff. In my Deploy task I tick the This project is parameterised box and I selected the Promoted Build Parameter, the configuration for this step is a very standard one, I just selected the Build project and the rest is automatic. This step enables me to select which promoted build I want to deploy, but this is where the big problem resides. The value that this "step" returns is something like this https://site.name.com/job/ProjectName/137/.

The problem that this create is in Copy artifacts from another project. I need a build number, but I only have that URL, so the solution that I found was to get the build number from that URL, inject that number as a local variable and use that local variable in the next steps.

Build steps

With this solution I'm able to deploy only the promoted build.

cunhaf
  • 1,057
  • 1
  • 8
  • 12