Jenkins - Pre-build event - jenkins

How is that possible to add Pre-Build actions in Jenkins, exactly like it's Post-Build ?
I've came across Conditional BuildStep, Run Condition and Parameterized Trigger plugins, but can't find out a way to add that.

Sadly there is no real pre-build event because not every pipeline may build something.
You can disable the default checkout by using the option skipDefaultCheckout and manually do the git checkout later using the command checkout scm. I think this is the closes you will get to reach a Pre-Build-Stage.

Related

Jenkins declarative pipeline, trigger my job whenever there is change in symlink

I am currently trying to solve an issue where I am not using Git for any purpose rather we just want to use Jenkins to trigger our pipeline whenever there is change in the symlink located in a folder and not in the workspace
I suggest that you'll try to use https://plugins.jenkins.io/fstrigger, even that it may not really being supported currently.

How to trigger a Jenkins build on a Perforce submit

I am using Jenkins with Perforce. I have downloaded the P4 Plugin, and I have read over the documentation but I am still a bit confused. In my Jenkins project, I have the build trigger set to "Perforce triggered build". I'm assuming that means I need to add a trigger to Perforce that tells Jenkins to run a build, but I have no idea on how to do that.
I have not been able to find any documentation on how to implement a trigger from Perforce to notify Jenkins it needs to run. I can find documentation from Perforce on how to setup basic triggers, but I can not find anything from Jenkins on how to set up the actual connection to trigger builds on Perforce submits.
On the "Changes" tab in Jenkins, I am able to see the what was submitted to Perforce, so I know that Perforce and Jenkins are at least communicating. Initially, I thought that Jenkins would just automatically run the build on a Perforce submit, if I had "Perforce triggered build" checked, but that doesn't seem to be the case.
So my questions are:
Am I correct in assuming that I need to manually create a trigger to be added to Perforce?
If so, does anyone know of any documentation or examples that I can look to as a guide?
Yes, you need to add a trigger to Perforce. It's well documented here.

How to tag a passing build?

I saw a configuration option that allows tagging every build, but it seems this would just needlessly pollute the tag history. Is there a way in Jenkins to tag a build only once it has been marked as passed?
Absolutely, using the Flexible Publish plugin.
This plugin will allow you to wrap post-build actions in a Run condition.
All this really boils down to is, installing & using that plugin, you can wrap your git publish in a Run condition using the Current build status as it's condition, setting it to only run when the entire build has passed (success).

Conditional Post-Build step in Jenkins without plugins

For my post-build step, I will be executing Sonar analysis (from SonarQube plugin) and a script that I wrote. I don't want this to run all the time and want to trigger the post-build step with a boolean parameter. Is there anyway to do this? Ideally, I want to have a checkbox that determines if the Post-Build step will execute in the Build-with-Configurations page.
You could use the Promoted Builds Plugin to start further steps after a build. This can be done either manually (I think that's what you're looking for) or based on some logic you've defined.

Conditional Builds (when something has changed) in jenkins

Is it possible to do conditional build in Jenkins? for example every 5 mins it checks source control for new commits and will only build if there has been changes? we are using git at the moment.
You can set up Jenkins to poll your VCS and build if there are changes but better would be to use a post-commit trigger. 'Polling must die: triggering Jenkins builds from a git hook' will give you the info on setting that up.
I use Build triggers -> Poll SCM and doesn't really see the problem in using that system.

Resources