How to add a specific post build action in jenkins for multiple jobs in one shot? - apache

I need to add a post-build action(Deploy to container) to 23 jobs at a time. Is there a plugin to do that to make my work easy?

You have two solutions:
Either you update the post-build actions for each Job
Either you are able to script your post-build action using Postbuildscript's plugin: https://plugins.jenkins.io/postbuildscript And you call this script in your post-build action
Benefit of the second solution, is that you will have to update your job's configuration only once. Then you only need to maintain your script.

Related

Bamboo Workspace Handling

I'm not really sure if I got bamboos workspace handling right...
We have the following situation:
stage1:
job1: scm checkout
stage2:
job2: build1
job3: build2
stage3:
job4: build3
job5: build4
The repositorys size is about ~1,5 gb. Therefore, after every build, I want to delete everything except the build artefacts on my agent. But if I delete something on my agent in stage2, my jobs in stage 3 only get the "cleaned" ws. Is this default behaviour? And if yes, how can I prevent that my agent gets "dumped"?
x jobs = x*1,5gb ...
If you want to delete the working dir, go to Job configuration / Miscellaneous tab and check Clean working directory after each build.
I haven't found this option in the documentation, anyway its there (Bamboo 6.0.3)
Also note, that if you have more than one agent, jobs might run on any of them (concurrently). So job1 (checkout) could theoretically run on another machine, than the rest. You can solve that with Tasks, which always run inside one Job, thus one agent.

Any way to auto-modify an action?

Is there any way to auto-modify an action on Photoshop? For example, multiple workers use our internal action pack and I wanna be able to modify something without having them to replace/load the actions each time, is that possible?
Maybe a action that runs a script that runs the actions from folder? So changing the actions on folder would change the actions when they run?
So I basically found what I need http://www.tonton-pixel.com/scripts/utility-scripts/play-actions-file-action/index.html
But it opens the little screen each time asking which action I wanna play... any way to make it directly?
You need a script for that. If you still want actions, then an action that runs a script that runs the actions from folder would work.
Ideally you'd abandon Actions all together and redo them as scripts (there's a script that converts actions to scripts files) and then actions may call those scripts on a server, so you can modify every step without telling people to reload .atn files.
Advantages of scripts will be:
as I mentioned, easy to modify;
you can have one undo for a long script (in actions 1 undo = 1 step);
much easier to trace/fix errors;

How to run the same job against multiple repositories with multiple triggers?

So I'm actively trying to circumvent the job limit bamboo has in place because I have many inactive repositories that get fixed occasionally when new platform updates come out or a one-off new feature is added.
What I would like to happen is for my repository polling to pick up that there's been a change on one of my repository branches, run the job, and presto-change-o we're back to square 1 where I'm listening again for another repository polling update from another change.
Example:
Repo 1 has a commit pushed
Bamboo "hears" the change and starts the job
Repo 2 has a commit pushed
Bamboo hears this change as well, but doesn't continue due to 1 agent being available, this change is queued for later
Repo 1's triggered update finishes and publishes an artifact that can be shared
Bamboo resolves and starts Repo 2's job
Is doing something like this even possible? The best solution (meh) that I've found thus far is to just create one job with a sequential build where it's basically checkout/build/checkout/build/checkout/build but that would result in having to run through many unnecessary steps should I poll only one update from one repository. It's not like these things are changing frequently.
You can add multiple repositories to your build plan, and in your repository polling trigger put checkboxes on all repositories added into the plan.
To add multiple repositories,
Open Plan Configuration Editing
Select third tab "Repositories"
Press "Add repository" button.
Configure your repository and save.
Select fourth tab "Triggers".
Open your Repository Polling trigger and select all repositories you've added on steps 3-4.
Save the trigger.
Then repository polling has to check all configured repos, according to documentation:
https://confluence.atlassian.com/display/BAMBOO058/Triggering+builds
You can also add additional repositories into Source code checkout task, and checkout every repository in different subdirectory.
E.g. for repos R1, R2, R3 you will have working copy directories ./W1, ./W2, ./W3.
And Then it's up to you - either you clone your assembler task T to T1, T2, T3 to make builds from each working copy correspondingly, then it will be done for all jobs on every commit, they will all produce artifacts with the same build number, or you can add a shell script task and write a shell script which discovers the latest commit among all working copies (let's assume it is ./W2), creates symbolic link to that working copy subdirectory as ./MySymbolicLink, and your job that assembles the build will do that from ./MySymbolicLink folder.

Is it possible to add incrementing id number to IntelliJ-IDEA run executions?

Is it possible to add incrementing id number to IntelliJ-IDEA run executions? I want a unique env variable to increment by one each time I run a test execution. Sorta like how Jenkins keeps track of build# .
There's no direct support for this feature in IDEA, so you'll have to code something yourself. However, in the run/debug configurations there is an option to perform various actions before running. So you could, for example, write a gradle task to increment a build number and have IDEA run this task each time you execute your app.
If you add this to the defaults then it will get picked up for all your run configurations and you won't have to remember to add it in each time.

Splitting Jenkins Job to run concurrently

Does anyone know of a way to split a single Jenkins job into parts and run them concurrently/parallel?
For example if I have a job that runs tests which take 30 minutes, is there a way I can break this job into three 10 minute runs that run at the same time but in three different instances
Thanks in advance.
Create new jobs, call it f.e. Test . You should select the job type based on the type of the root job.
If you have a Maven Job type, you can set the workspace directory under build -> advanced. Freestyle Job type has this option directly under project -> advanced.
Set for all jobs the same working directory. The root job will compile and all other jobs uses the same working directory to use the compiled output.
For the test jobs add the test execution as build step and differ here the tests which should be executed.
Edit your root job and remove there the excution of the long running tests. You can call there the three jobs now. But you need the Parameterized Trigger Plugin.
The downside of this way, you need enough jenkins executors to handle all tests jobs.
If you're using Jenkins 1.x, I would suggest trying the multijob plugin - I've successfully used it to split a single job into a parent job plus multiple child jobs:
https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin
If you're using Jenkins 2.x, then try out the pipeline feature :) It makes running parallel tasks very easy:
https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md#creating-multiple-threads
If you want, I believe you can also use pipelines in Jenkins 1.x by means of a plugin. I haven't looked into that, though.