How to receive inputs from UI to jenkins - jenkins

I want my jenkins job to take inputs from the UI and pass them as parameters while building . parameters can be url or files or both. Is this possible in jenkins? If yes, can someone help me how this can be done?

You can define parameters by selecting "This build is parameterized" in your job configuration. There are several parameter types built-in and several plugins will provide additional types.
See https://wiki.jenkins.io/display/JENKINS/Parameterized+Build.

Related

How can I set up my Jenkinsfile so that some params only appear if another param is selected?

I am working on a multibranch pipeline so all of the parameters are defined inside the Jenkinsfile. I'd like to know if there is a way that I can set it up so that if I am inside "Build with Parameters", and I click on a checkbox that I have defined in the Jenkinsfile, more parameters appear as options.
I just want to reduce clutter and confusion when someone wants to build my pipeline. I have so many parameters and a lot of them are unnecessary unless one checkbox is clicked.
If this isn't possible, I'd love any other suggestions to make my parameters section more organized.
Thanks!
For your case, you can use Active Choices Plugin available to download from Manage Jenkins >> Manage Plugins.
In the documentation page of this plugin, you can find various examples which will you to understand and setup.

Is there a way to use parameters in Jenkins job description field?

I have a job creator job that creates other jobs in jenkins and I would like to use the created jobs name in the description.
For example for name "JobXX" i would like to have:
"This is documentation for JobXX etc.."
In "Execute shell" build step I can refer to the jobs name via $JOB_NAME parameter but that does not seem to work in the description field.
Any ideas on how to do this? Or if it's even possible?
Never used it, but take a look to the Project Description Setter Plugin:
https://wiki.jenkins.io/display/JENKINS/Project+Description+Setter+Plugin
In this blog it explains better how to use it:
http://www.tothenew.com/blog/setting-dynamic-project-description-and-build-description-in-jenkins/
Among the different variables you can use there is {PROJECT_NAME} which fits your needs.
Besides this, this plugin allows you also to automatically set descriptions to each specific build.

Jenkins same parameters on multiple jobs

we have many Jenkins Test Jobs dependening on one library. Every Job has multiple parameters (always identical).
Now the problem is that if we change or add an parameter in the library, we have to touch every single jenkins job configuration.
Is there a way to configure the parameters of multiple jobs in a central place? Like defining the parameters in a file and refering to that? or is there jenkins plugin for that use case?
Thanks,
Marco
You can edit parameters (and much more) of multiple jobs in one place with Configuration Slicing Plugin:
Job Parameters (aka "This build is parameterized") can be configured across multiple jobs at one time through the "Parameters" link. To indicate which parameter you are configuring, note the "JobName[ParameterName]" syntax.
Not sure if this can help if you use some advanced parameters like File parameter, Dynamic parameter etc.
Use Build Flow plugin
You can run same or multiple jobs many times with different configuration.
Use Multijob Plugin and parameterized plugin
You can pass different parameter by using these plugins

How to call a jenkins Job based on User inputs

The issue here is once the first Job in a Jenkins pipeline is done, we need to ask some inputs from user and based on the user Inputs to decide the next job to be triggered(Job2 or Job3)
tried build flow and parameterzied trigger plugin but didn't find any suitable option under these.
Any other plugin or jenkins feature which can help in achieving the above scenario?
There are a few plugins I have tried which collect user input on manually triggered jobs in a build pipeline: Active Choices Plug-in 1.2 and Extensible Choice Parameter 1.3.2.
With Active Choices you define a list of selections and a default value. With Extensible Choice Parameter you can have a text box and a default value.
This is how they work for me in Build Pipeline 1.4.8 on jenkins 1.628
If you run the manual step directly in the pipeline the default is used and other parameters propagate through correctly.
If you open the step there is an option to Build with Parameters which will ask for the user input. This works but other parameters like the build number do not propagate through so the pipeline is broken, and the pipeline screen does not show the status.
Jenkins will never pause and ask a user for inputs. It is an automated build system. It doesn't expect anyone sitting at the console watching the progress.
You can provide "inputs" or parameters when you manually trigger the job, i.e on the first job in your pipeline. You can them pass these parameters to downstream jobs, either through the Parameterized Trigger plugin or through a file copied between jobs.
If you need a human decision in the middle of your build flow, consider Promoted Builds plugin. With this plugin, a human can select a build, and then decide which "Promotion" to execute (which could branch your workflow as you need). The promotions can also be automated if needed, based on criteria and not human input.

Adding a parameterized parameter to a jenkins job

I need to add a same boolean parameter ( from "Add Parameter" drop-down menu) to 100 existing jobs.
What is a better way to do it?
Thanks
This is a job for Jenkins job-dsl https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin
This exposes the job structure to an API which can be used to modify the configuration. This is run as a separate Jenkins build step in a job
There is also a somewhat unwieldy, yet oftentimes-handy, plugin called Configuration Slicing. I've found it useful sometimes, in this situation.
Use Build Flow plugin. It allows to write DSL scripts.
example:
build("job-name", parameter:"vlaue1")
build("job-name", parameter:"vlaue2")
you can pass as many values like this.

Resources