jenkins promoting builds with Paramaterized build parameters - jenkins

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

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.

Related

Trigger a downstream project on demand

Given the following situation
main-job builds and tests a project
installer-job copies artifacts from main-job, and packages them into an installer
installer-job is set as downstream project of main-job via Parameterized Trigger Plugin.
But the installer-job should only be triggered on-demand from main-job's build page.
It's possible to trigger the downstream job on the project page:
But it doesn't seem possible to trigger the build from a specific build page.
Is there any option to get such a trigger button on the build page?
Note: It's a freestyle project, not a pipeline one. So things like the Build Pipeline plugin don't help, unfortunately.
An elegant solution is possible via the Promoted Builds Plugin. "Promotion" is some activity that's performed when a build fulfills certain criteria, like
build was successful
all downstream builds passed
explicit, interactive confirmation
In your case, this condition will be simple: just "main-job" needs be successful, and you will want to confirm explicitly.
There's lots of possible steps that can be triggered as promotion activity -- what you want is to trigger a build of the "installer-job", which can be configured easily.
To summarize, for "main-job", you will configure something like this:
When you do that, the 'main-job" builds will feature a "Promotion Status" button. After pressing the "Approve" button there, the promotion will be enabled and the "install-job" will start building:

Jenkins executing one job that runs multiple jobs

i am new to Jenkins , i need to execute one job that run's another multiple jobs in parallel were it should not stop even if one job fails.
i am not sure how to achieve it. After googling i can achieve by 3 ways Multi-Job plugin , Pipeline multiple Jenkins jobs , Build after other projects , Build Flow Plugin.
can any body please provide me the correct way.
Update : i am trying to achieve this using the pipeline plugin , can any body suggest me were it was correct choice ?..Please suggest!..
We use the Parameterized Trigger Plugin to do this.
In your build configuration add a Trigger/call builds on other projects build step. Add the names of the builds you want to trigger as a comma separated list and make sure that the Block until triggered projects finish their builds box is unchecked. Your build will trigger each of the listed builds, however note that your parent build won't wait for them to finish it will just trigger them and then perform the rest of it's buildsteps so if you have buildsteps.
If you do want to wait then check the block until triggered builds finish box, but set the options for when to fail the build, build step or mark the build as unstable appropriately.
If you need to pass parameters to the jobs you can add parameters using this plugin. If your downstream jobs need different parameters for different jobs you can click the add trigger button which adds another project to build where you can specify different options.
If these other jobs are follow up jobs to the current job and you don't need to wait for them to finish you can also achieve what you want to do by using the post build action build other projects, but again this occurs after the current job and you won't be able to use the results.
can any body please provide me the correct way.
I wouldn't approach using Jenkins with a "one correct way" mentality. Often times the requirements of your build will dictate which method or plugin you use in your build configurations.
The job can start other jobs via the jenkins api.
updated Answer : i used pipeline plugin to achieve my task and tuffwer was right to if u have paramaterized trigger plugin!..

Run a jenkins job without triggering its downstream jobs

I have a jenkins job named "a", that triggers job "b" after it finishes successfully (job "b" is on the down-stream of job "a")
Is there a way to run job "a" without automatically triggering job "b"?
Maybe some kind of plugin ?
Disable job "b". Then it won't run even when it's getting triggered from "a".
If you need a more dynamic/automated solution, then you can also disable/enable job "b" from within job "a".
If you check your configuration on the UPSTREAM job, you must have added a POST-BUILD step, just as shown below and there would be a possible selection out of what is displayed here. The Job B that you talk about, it will be triggered based on the outcome of Job A and by the choices that are available, it will be triggered irrespective of the choice that you make from the drop-down.
Hence the only option left out is to DISABLE it, on scenarios (the outcomes of Job A) that you think where Job B should not be triggered.
Hope this helps!
Post-build action in job "a" that is of a type "Trigger parameterized build on other projects" will trigger project "b" automatically. Replace the post-build action with type "Build other projects (manual step)".

jenkins to get build number from 2 different jobs

Right now I use "Run" parameter in a job that retrieves last successful build of another job to this job. This parameter gives me a dropdown of all last successful builds and I can manually choose any build and use it in my current job. But now I want to extend it to choose last successful build from 2 different jobs i.e. my current job should be able to see all successful builds in 2 different jobs and be able to choose any job of the choice. How do i do this in Jenkins. (Note: I do not want 2 different Run parameters- one for each job. It should be a single choice)

How to execute only the most recent queued job in Jenkins?

I've got a commit build project in Jenkins which schedules an acceptance build project on completion. Since commits come in faster than the acceptance build job finishes, after a short time there are now six queued acceptance build jobs. I would like the acceptance build project to work like the "Poll SCM" functionality - On completion, start the most recently queued job, skipping the rest.
I can't use the "Build after other projects are built" without more hacks since I need to pass information from the commit build job to the acceptance build job.
#l0b0,
Jenkins behavior is to coalesce builds so that the queue only contains the currently running build and one enqueued job. The depth only increases if the newly enqueued jobs takes parameters that differ from what's already on the queue.
So I'm gathering that your downstream (acceptance) job takes some sort of parameters, but you need to supply more details of how it's working.
If you're using parameterized trigger plugin then you should check out this existing SO thread
More generally speaking, you should look into your parameters. It sounds like you are passing too much information from upstream to downstream jobs, resulting in the the Jenkins queue treating them as distinct parameters when then is not necessarily the case.
Are you passing in the run number of the last successful upstream job as a parameter? If so, then yeah you've got problems. What you should do instead is use the Promoted Build Plugin on the upstream job to mark the last successful build, and then have the downstream job simply jump to the most recent promoted build.
Hope that helps.

Resources