I installed the Promoted Build Plugin
from Jenkins
and now I'm facing some troubles to promote a build from an existing job. Here is the scenario:
There is an existing Nightly Build
job that runs every night running all the tests and metrics needed;
There is an existing Deploy Build
that accepts a parameter ${BUILD_NUMBER} and deploys the build that has the corresponding ${BUILD_NUMBER} from the Nightly Build
So far so good. Now is the part where I want to add the Build Promotions
...
Is there a way to promote the Nightly Build #39
(notice that it was already built before) from the Deploy Build
? Or maybe even from somewhere else, quite frankly I`m kind of lost here :(
I don`t see them with a clear Upstream/Downstream relationship, because they don't have a: always runs this build and then the other during the execution - the [Deploy Build] is executed sometimes only and not always after the [Nightly Build].
With version 2.23+ behavior changed (thanks AbhijeetKamble for pointing out). Any parameter that is being passed by Predefined Parameters section of calling (build) job has to exist in the called (deploy) job. Furthermore, the restrictions of called job's parameters apply, so if the called job's parameter is a choice, it has to have all possible values (from promotions) pre-populated. Or just use Text parameter type.
Yes, I have the exact same setup: a build job (based on SVN commits) and manually executed deploy job. When the user selects any build from the build job (including older builds), they can then go to Promotion Status link and execute various deploy promotions, for example Deploy to DEV, Deploy to QA, etc
Code A:
Server=IP_of_my_dev_server`
Job=$PROMOTED_JOB_NAME`
BuildSelection=<SpecificBuildSelector><buildNumber>$PROMOTED_NUMBER</buildNumber></SpecificBuildSelector>
Above, in the Predefined parameters section, the name to the left of = are the parameters that are defined in your deploy job. And to the right of = are the values that will be assigned to those parameters when this promotion executes. Defines three parameters Server
, Job
and BuildSelection
.
The parameter Server=
is my own, as my deploy job can deploy to multiple servers. However if your deploy job is hardcoded to always deploy to a specific location, you won't need that.
The Job=
parameter is required, but the name of the param depends on what you've setup in your deploy job (I will explain configuration there). The value $PROMOTED_JOB_NAME
has to remain as is. This is an environment variable that the promotion process is aware of and refers back to the name of your build job (the one where promotion process is configured)
The BuildSelection=
parameter is required. This whole line has to remain as is. The value passed is $PROMOTED_NUMBER
, which once again the promotion is aware of. In your example, it would be #39
.
The Block until the triggered projects finish their builds check mark will make the promotion process wait until the deploy job finished. If not, the promotion process will trigger the deployment job and quit with success. Waiting for the deploy job to finish has the benefit that if the deploy job fails, the promotion star will be marked with failure too.
(One little note here: the promotion star will appear successful while the deploy job is running. If there is a deploy failure, it will only change to failure after the deploy job finished. Logical... but can be a bit confusing if you look at the promotion star before the deployment completed)
Server
(this name has to match with configuration in promotion's Predefined Parameters in previous section)Job
(this name has to match with configuration in promotion's Predefined Parameters in previous section)Job=
from Predefined parameters that we configured). Also, if there is no value passed from promotion's Predefined parameters, the first choice value will be used. If you have a 1-to-1 relationship between the build and deploy jobs, you can omit the Job=
parameter in promotion's configuration.BuildSelection
${Job}
Specified by a build parameter
BuildSelection
(without ${...}
!)So now, with the above deploy job, you can run it manually and select which build number from build job you want to deploy (last build, last successful, by build number, etc). You probably already have it configured very similarly. The promotion on the build job will basically execute the same thing, and supply the build number, based on what promotion was executed.
Let me know if you got any issues with the instructions.