Jenkins: start build of multiple project, based on Boolean parameter - jenkins

I have a job with "This project is parameterized" checked. I use "Boolean Parameter". I have such parameters - 50 of them in this job. Each param contains the name of another project and "Default Value" checked or unchecked. I need, when I start this job, a check to be made. If the value is checked, I need the job, which name is in the "Name" field to be triggered and built. The unchecked object needs no build at the moment. Below are some images for clarity. I cannot use any plugins since I do not have permission to install them. As a hint I was told that it is possible to be done with ssh??? but I am not sure about that.
I see that there is this option called "Build other projects", but I need to build only the one having checkboxes ticked. After a whole day spent in research, I was not able to understand how to configure this relation

Related

TFS 2017 vNext Build: Customize fields on bugs created on build failure

I am creating task-based builds in TFS 2017. The builds have an option (under the 'Options' tab) to create a Bug automatically when the build fails.
When the build fails and a Bug is created, the bug says it was created by me. I assume this is because I am the one who set up the build definition. However, I am not usually the person who kicks off the build, nor do I check in code for this project. I would like to change the default "Created By" value to either a team member who is responsible for fixing broken builds, or a generic value like "DevBuild".
The "Create Work Item on Failure" area has an "Additional fields" section that I wonder if I could use for this, but I'm having trouble working out if that's what it's for and how it might be used.
The help prompt reads:
Additional fields to set when creating the Work Item.
For example, "System.Title" = "Build $(build.buildNumber) failed" will
format the Work Item title, and "System.Reason" = "Build failure" will
set the reason.
So I tried this, but to no avail.
Is there an option for changing the Created By field? Is there a list of possible field values I could use here to change other parts of the bug?
Your setting is correct. Once you add System.CreatedBy field, the value of Created By field will be reset.
You could run a query and select Created By column to check the values:

Jenkins GUI to set time - is there a way to pass parameters from the "build with parameters" screen to the a schedule

I have a couple of jobs with parameters, that let developers choose params from the "build with params" screen.
Now these jobs need to run nightly. BUT -
The nightly parameters' values must be changed every couple of weeks, by some developers.
The developers who must change these values can't have permissions to edit the jobs, just to build them.
So I'm wondering if I could pass some parameters to either the "build periodically" or to the "build periodically with parameters", such that would enable the developers to set the time of a build from the "build with params" screen. Parameters like "minute", "hour" and so on, that will be written in the build periodically" like so: ${minute} ${hour} ${DOM} ${Month} ${DOW}.
This will enable the devs to set a nightly build on their own, or even an afternoonly or morningly, without editing the jobs... What do you say?
I see that the the "build peri" gives an error for adding ${minute} (invalid input). Could this be done in some other way?
I ended up giving the dev team a multijob that's built periodically, runs the jobs with predefined parameters, and is editable by the devs.
That gives them an not-really-GUI-place in which to set params and a schedule to the jobs without editing the jobs themselves. Doesn't look like much but it solves my problem.

Get the list of Projects under selected solution in TFS Build definition

Is there any way by which i can get the number of projects under selected solution in my build definition.
I am creating a parameter of type Drop down List, which should be got filed by the number of projects (.csproj) the solution has.
I have to do this calculation before queuing the build, so that i can ask the user to select any of projects from list to deploy.
Can anybody tell me how can i do this in TFS Build template.
I don't think you can calculate the number of projects under a selected solution in Build Definition. Metadata about a process parameter contains a piece of information Editor, this is a string that specifies a custom editor for the parameter, there is not a method to calculate the number of projects under a selected solution in Build Definition. See the Editor Attribute help for more information on the syntax.

Copying and Editing Jenkins Jobs

I have been using Jenkins for a couple of months now, and have been able to set up a simple CI system.
I currently have a build tab - that will build and deploy 25 different components successfully, based on building from an SVN trunk.
I'm now taking my first branch - some people will develop on the trunk and some will develop fixes on the branch.
I would now like to have CI up and running for both branch and trunk - so would create a second tab - with a repeat of the jobs from the first tab, but this time changing the SVN path to check out from the branch.
As I have rather a lot of jobs and the task is quite repetitive, is there an easy way to do this ? I'm hoping that each job tab might be a single xml that I can edit / rename to give me a second tab ?
Yes, each job is as single xml file, located under $JENKINS_HOME/jobs/$JOB_NAME/config.xml. However there are a number of places in the config.xml that reference it's location, so simply copy-pasting the actual file isn't the best option.
Jenkins UI itself has "copy job" function.
Click "New Item" where you want it
Select "Copy existing Item"
Specify the name of existing item to copy
Specify the name for the new job
Then go to configure the new job and change what you need.
Another tip: may not apply to your setup, but more often than not, there is a "unifying difference" between multiple similar jobs, most often a branch name, or project name, or similar. The value would be that only one that needs to change between otherwise identical jobs, however that changed value may appear several times within the job configuration.
I usually make a "choice" parameter, with a single choice, and put that different value there. The rest of the job references the choice param as a variable. So when I copy identical jobs, I just need to change that 1 value at the top of job configuration page. Everything else falls into place.

Runtime build configuration in hudson build

My project uses ANT build system. Currently, I am giving build via shell command for my project. Say when I give "ant dev deploy" from cmd prompt(see below image for a successful build via cmd prompt) the build starts and in between it stops for confirmation from user. In the below image, I have highlighted the runtime value passed "dev", which is passed as a confirmation variable, then the build continues based on the value passed.
This is how it should be and it was working correctly till now.
![Successful ANT build via cmd prompt][1]
Currently I am automating this build via hudson. I have given the value "ant dev deploy" in the targets of the Build properties in hudson. But, now I dont know how to configure to get the value "dev" in between the build progress. During my trial, I was getting error for that. Below, I have given the logs from Hudson.
Is there anyway I can pass the value on runtime.?
Sorry I am not able post images. Can clarify if any questions.
Oops! Your question couldn't be submitted because:
•We're sorry, but as a spam prevention mechanism, new users aren't allowed to post images. Earn more than 10 reputation to post images
You cannot pass a value to Hudson in the middle of the build. You need to supply that at the time of triggering the build. Hudson is not interactive, so anything in your current process that requires user prompting half way through needs to be redesigned.
All your user prompting needs to be done through build parameters at the beginning of the build. In the job configuration, check mark This build is parameterized. If you want to restrict the possible values, a "Choice" parameter is best. Give it a name, for example CHOICE1, give it a list of possible choices. When the build is manually triggered, the user could choose one of the choices from a drop-down, and then start the build. Note that this will not work with builds that are automatically triggered.
Next, you need to pass this value to your ANT script. In your Invoke Ant build step, click "Advanced" button, and under "Properties" you can pass variables to your ANT script:
antScriptVar=$CHOICE1
Above, $CHOICE1 is the reference to the Hudson build parameter, it will contain the value the user selected from the drop-down when starting the build. The antScriptVar is your variable in ANT script that will have this value. You can define the empty variable in ANT script with
<property name="antScriptVar" value="" />
When Hudson triggers the ANT script, it will populate this variable with the build variable. From then onwards, use it like you would any other variable in ANT

Resources