jenkins waiting for a event to happen - ant

What is the best way to allow jenkins to act on something when a event happens, meanwhile it can wait for the event?
I was thinking of writing an ant script that can prob a process that it started to see if it had completed yet before moving onto another task, but I'm not sure it's a good idea to do that, perhaps just use a shell script? Just wanted to know what is your experience with doing something like that.

Jenkins should not wait. A job build should be triggered from the 'something' event. This can be acomplished by a wget on an URL like http://jenkins.myserver.com:8080/job/myjob/buildWithParameters?delay=0sec&myparm=42. You can also use the jenkins CLI.

try this plugin: https://plugins.jenkins.io/webhook-step/
As per the documentation: This pipeline plugin provides an easy way to block a build pipeline until an external system posts to a webhook. It can be used to integrate long running tasks into a pipeline, without busy waiting.

Related

Azure devops pipeline triggers

I am trying to build a pipeline that gets triggered by other pipeline and should not be able to be queued by itself. I am unable to find a way to do the same. Any help would be greatly appreciated.
Updated:
Structure i am looking for is PipelineA triggers PipelineB and waits for PipelineB's completion. If i add a trigger saying start when completed it wont trigger PipelineB since A is technically not complete.
Thanks
Assuming you are using Azure DevOps, you can add a pipeline trigger to run your pipeline upon the successful completion of the triggering pipeline.
To prevent triggering two runs of a pipeline, you must remove its own CI trigger or pipeline trigger.
We do not have this build-in feature at present. You need to customize yourself.
Triggering a pipeline can be done via the API and trough PowerShell. You can write your own script file and use the PowerShell tasks.
Then you could use Rest API to query to build result for you have triggered above.
Finally use a task Conditions.
Inside the Control Options of each task, and in the Additional options
for a job in a release pipeline, you can specify the conditions under
which the task or job will run.
Unless the query result of you trigger build PipelineB is completed/succeed. Then you could continue to run left tasks in Pipeline A

Monitoring external event job progress using Jenkins

How can I make an external job appear on a Jenkins dashboard more like a native Jenkins job, specifically including a progress 'bar'?
I've come across https://plugins.jenkins.io/external-monitor-job but this only appears to provide a way to say
My jobs has finished with this console output and this result code.
I would also like to see things such as current progress. Or to put it another way, I'd like my external job to be able to appear on something like https://kj187.github.io/dashing-jenkins_job/ in a similar manner to a native Jenkins job.
So is it possible to push more data than the external-monitor-job suggests?
Create a free style job and monitor the external process (print logs etc.) in the free style job - read the logs till logical conclusion in the freestyle job
What about pipeline view plugin?
Steps will be:
v1 (manual way)
create a job called monitoring_external_process inside pipeline view. This job performs a kind of ping looking the end of your process.
start your external process in a separate way.
go to jenkins monitoring_external_process job and press build.
a progress bar will be showed until the end of your external process.
v2 (automatic way)
create a job called monitoring_external_process inside pipeline view. This job performs a kind of ping looking the end of your process.
configure a webhook trigger or remote build for this job. This enable a public url to invoke the jenkins job. (See link reference #2)
configure your external process to perform an htttp request to the public url.
start your external process in a separate way.
Automatically your job will be started and progress bar will be showed until the end of your external process.
References:
(1) https://code-maven.com/jenkins-pipeline-hello-world
(2) https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks

what jenkins can do other than build?

I have some processes or I can call them as events and after completion of that processes or events I wanted to kick start the backup processes. Is it possible with jenkins? if yes then how to do it? if not what is other the solution.
Thanks.
I would recommend the Jenkins Multi-Job Plugin
This plugin allows you to define conditional steps which only run when the previous step was successful. I use this plugin heavily and highly recommend it to anyone looking to use Jenkins to automate a multi-step process.
https://wiki.jenkins-ci.org/display/JENKINS/thinBackup
You can use this thin backup plugin also.
You have two options :
Write a post build action to get the backup. For this you can use shell script to where how and what kind of backup you want.
Create another job which is responsible for backup. you can trigger that job after successful completion of all your events.

How to fire an alert when a Jenkins job runs for too long?

I want to be alerted when my Jenkins jobs run for too long.
I didn't find such a plugin, do you know of such a plugin, or another way to do it?
Thanks!
As far as I know there is no such plugin or configuration available. There is buildtimeout-plugin, which will abort the build on a given timeout, but AFAIK doesn't support just giving an alert and not aborting.
if you're willing to make a custom build of the plugin, it might be reasonable to extend that yourself. Like you can see from its source code, it defines a general BuildTimeoutOperation interface which should be extendable to give an alert on build timeout instead of aborting a build. The existing implementations of the interface could give you some ideas on how that would be done.
Try this,
For sound & mail alert :
-> Use Jenkins Sounds plugin & build triggers to achieve your task.
Create a separate job for alert and trigger the job when you want. (stable, unstable or failed)
In that same job itself, you can configure email notification.
To find long running job, Use parallel (time counter configuration or use build-timeout plugin) job. If it takes time more than specified then trigger an alert job (configured with sound or email)

Is there a possibility in jenkins to run build only if something changed (in ClearCase SCM) from last build?

I need to build in jenkins only if there has been any change in ClearCase stream. I want to check it also in nightly or when someone choose to build manually, and to stop the build completely if there are no changes.
I tried the poll SCM but it doesn't seem to work well...
Any suggestion?
If it is possible, you should monitor the update of a snapshot view and, if the log of said update reveal any new files loaded, trigger the Jnekins job.
You find a similar approach in this thread.
You don't want to do something like that in a checkin trigger. It runs on the users client and will slow tings down, not to mention that you'd somehow have to figure out how to give every client access to that snapshot view.
What can work is a cron or scheduled job that runs lshistory and does something when it finds new checkins.
Yes you could do this via trigger, but I'd suggest a combo of trigger and additional script.. since updating the snapshot view might be time-consuming and effect checkins...
Create a simple trigger that when the files you are concerned about are changed on a stream will fire..
The script should "touch/create" a file in some well-known network location (or perhaps write to a pipe)...
the other script could be some cron (unix) or AT (windows) job that runs continually or each minute and if the well-known file is there will perform the update of the snapshot view..
The script could also read the Pipe written to by the trigger if you go that route
This is better than a cron job that has to do an lshistory each time.. but Martina was right to suggest not doing the whole thing in a trigger for performance and snapshot view accessability for all clients.. but a trigger to write to a pipe or write some empty file is efficient and the cron/AT job that actually does the update is effieicnet as it does not have to query the VOB each minute... just the file (or only after there is info on the pipe)..

Resources