Reputation: 7877
In a single Jenkins job, we can trigger a build by specifying a schedule
and also by polling
. But then, in both the cases, the build is triggered, and the deploy operation that I have configured as a post-build step (using PostBuild Task
plugin) also happens. I want that the build happens whenever a change is detected by polling, but deploy should happen only according to the schedule I have provided.
Is it possible to do it in a single job, or do I have to configure 2 separate jobs for them ?
Upvotes: 0
Views: 178
Reputation: 27485
You said you are using PostBuild Task
plugin. This allows to do a regular expression on the console log to determine whether to execute a task or not.
Builds started by schedule will have Started by timer
at the top of the log. All you need to do is add this expression to your PostBuild step under "Log Text" field. If you are already using some criteria in there, click "Add" button to add another "Log Text" field, and use the "AND" operator between them
Upvotes: 1
Reputation: 1072
It will be cleaner to do it in 2 jobs. However, if you really need to have it in one job, you could use a combination of Jenkins plugins to do the job.
Use Flexible Publish plugin, post-build action, to set up a conditional publish step when BUILD_CAUSE == SCHEDULED, or when BUILD_CAUSE_SCHEDULED == true. (Just test one condition.) Note that you'll need to use Jenkins' expression syntax, like so:
${ENV,var="BUILD_CAUSE_SCHEDULED"}
* BUILD_CAUSE_SCHEDULED is not its real name, you'll need to find this out on your own, sorry.
Upvotes: 1