1

I have Job A and Job B. Job A is having it's own few build parameters settings and Job B is having it's own other build parameters. Now, I want to promote few selected builds from Job A to Job B using promoted builds plugin by providing user inputs for the required parameters to Job B. Let me know how we can prompt and get the values for Job A build promotion.

Regards, Srinivas

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Srinivas
  • 321
  • 2
  • 5
  • 18

1 Answers1

4

For general usage of promotions with builds, read this answer How to promote a specific build number from another job in Jenkins?. It may give you ideas so that you won't have to pass extra parameters manually.

If you still need to provide parameters to Job B, here are some options:

  • Create multiple promotions on Job A triggering the same Job B, but with different parameters (through Parameterized Trigger plugin). This is essentially what I am doing in the linked answer. I have 1 deployment job (Job B) which takes various parameters for various environments. And I trigger it by having multiple promotions on build job (Job A), such as "Deploy to DEV", "Deploy to QA", and so on. Obviously this only works when you have a finite number of parameters to pass to Job B.

  • Use "manual approval" checkbox. When checked, you can further provide "Approval Parameters". The approving user will be prompted to provide those when clicking "Approve" button. Please note that "manual" approval parameters cannot be changed with "Force Promotion/ Re-execute Promotion" buttons.

Community
  • 1
  • 1
Slav
  • 27,057
  • 11
  • 80
  • 104
  • thanks for your reply Slav, this saved lot of time. I have tried second option which suited for me. Do we have an option to disable "Force Promotion" button in the promotion page and as well manual build option in the deployment job. We don't want let the build go with default parameter values. – Srinivas Apr 21 '14 at 17:30
  • The "force promotion" is there only for users with "promote" credentials. The "approve" button is there for everyone, unless approval is restricted to certain users (as configured in the promotion, not job/global security). A more detailed answer on that here http://stackoverflow.com/questions/23111888/why-do-i-see-a-force-promotion-button-when-using-the-jenkins-promoted-builds-p/23117369#23117369 – Slav Apr 21 '14 at 17:43
  • thank you Slav, I will go thru the link. In addition, I have the other query - if manual build option is enabled on deployment job, and if particular build id of build job is seleted for promotion, will it update build job's build promotion status? – Srinivas Apr 21 '14 at 18:00
  • You are asking if someone triggers the deployment job directly without going through the promotion process of build job? No. The deployment job is not really aware of the promotion process in that way. It could be possible with some fancy groovy script on deployment job. – Slav Apr 21 '14 at 18:36
  • Can you explain what is 'promote credentials'. In my setup the third person who is not listed in the approvers is also able to see 'Force Promotion' button. Let me know if I have to do pre-setup configuration. Basically, we dont want this button for any person including the approvers as well. will it be possible to disable it? also for the other query, I want to disable manual build on deployment job so that all builds should go through from build job as promotion builds only. – Srinivas Apr 22 '14 at 15:59
  • Under Global Security and/or under Job Security, you can configure a user with `Promote` permission. Such user will see the `Force Promotion` button. You do not need this `Promote` permission to use the `Approve` button. Check your user permissions. As for disabling manual build, this is really a topic for another question, but the easiest would be to implement a password parameter without which the job will not run. There are many tricks. Start a new question. – Slav Apr 23 '14 at 03:12
  • Hi Slav, the setup seems to be working now. Can you help me to find the cause for not able to use parameters in deployment job that are passed thru Dev builds. I have added new parameters like Branch,DevJOB,UploadVersion in predefined paramters section in Dev job and trying to access it in deployment job, but couldn't able to get the values in windows slave machine. Do we need define these paramters in deployment job first to use it. – Srinivas May 02 '14 at 18:23
  • 1
    You shouldn't need to create them on Deploy job. The passed parameters should be available as if they were local parameters of the Deploy job. Make sure your names are same. Make sure there is no space around `=`. Make sure your variable names are valid (no `.` for example). Remember that Windows use `%VAR%` instead of `$VAR` – Slav May 02 '14 at 19:29
  • I think i have used same way. I defined following settings in predefined paramters section of build job. Job=$PROMOTED_JOB_NAME Branch=$LABEL_VERSION Devjob=mBaaS-JS-SDK-Dev PROMOTED_NUMBER=$PROMOTED_NUMBER Uploadversion=5.7.preview BuildSelectionQAUpload= $PROMOTED_NUMBER – Srinivas May 03 '14 at 06:54
  • And now trying to fetch these values in depoy job in execute shell step of buildstep before SCM runs.
    echo "$Job,$Branch,$Devjob,$PROMOTED_NUMBER,$Uploadversion" echo "%Job%,%Branch%,%Devjob%,%PROMOTED_NUMBER%,%Uploadversion%" echo "${Job},${Branch},${Devjob},${PROMOTED_NUMBER},${Uploadversion}" I tried in 3 ways to fetch the values, only Promoted_Number value is getting.
    – Srinivas May 03 '14 at 06:56
  • I will go out on a limb at suggest that maybe it is not available because you are trying to access them "too early" in the "step before SCM". Just try accessing them in a regular build step. See if that makes a difference (I understand this is not what you want, but just try it). You can also use `set` command to see all variables, instead of one by one – Slav May 12 '14 at 13:39