what jenkins can do other than build? - jenkins

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.

Related

Add condition to transition using script runner

I am using the scriptrunner plugin for Jira.
Is it possible to add a condition to a transition using scriptrunner?
Currently, my condition is in a script which I have manually added to the workflow.
But I was wondering if there is a way to do it automatically?
I was looking through documentation on: https://docs.atlassian.com/
I came across this method:
replaceConditionInTransition which is a method of WorkFlowManager.
But I'm unsure on how to use this.
Any help would be appreciated.
Conditions as any another scripts can be added from file system. You can store scripts in any VCS (bitbucket, github, gitlab, etc) and automatically deploy them to Jira server file system through any CI/CD system (teamcity, jenkins, bamboo, gitlab, etc).
So, as result process will be looks like. 1. commit changes in you script to vcs 2. wait a bit for auto deploy (e.g. triggered by commit) 3. done. As additional you can write any script/service/etc for commit these changes automatically if needed.
Also look at script roots it's helpful way which allows reuse any of script fragments through helpers classes.
It's rather conceptual answer basically because implementation is depends on environment, but I hope that you get at least one more point of view to solve this task.
I think that using the Java API to modify Jira workflows is pretty tough. You could dig around in the workflow editor to see how conditions are added there. Remember that you have to do this in a draft workflow and then publish it, which takes some time in large projects
I like the idea of replacing a script file as easier, if it can be done when no issues are transitioning

Modify notifications on a running build in jenkins

I occasionally want to get notified when a particular jenkins job that is building finishes. Is there any way to do this?
Scripting it through the API would be fine. I already have the jenkins IRC bot that notifies me of many things, so if I could just dynamically modify the running job build, that would be enough to do what I want -- I'm just having a hard time finding how to accomplish that.
AFAIK, you cannot change a job's config while it's running.
Here is an idea: Use a post-build step to check for an external resource status (like a file containing an action by text) and running an action based on the content of the file.
The external file can be modified while the build is running, so when the post-build is executed, it will follow the logic defined based on the content of the file.
I hope this helps.
You can use email notifier, It will send you an email
https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

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)

To get build status through environment variable

I am using jenkins for continous integration.
For my build purpose, i triggering email using Ant task. I am not able to find an environment variable to pass ant for sending email build status(success/failure/stable).
i want to know how can i get environment variable for build status?..if not available, what is the alternative option for build status?
Thanks in Advance
varghese
Why use ANT to send emails from Jenkins when you have two great plugins that does just that?
The default mail notification is quite good, and if you would like to have more control
I suggest using the Email-ext plugin which is very comprehensive.
If still wish to use ANT to sent your mail-notifications including the status
you will have to break your process into two steps,
where the first part runs the build and the second one runs the ANT script to report the status.
In this case, you will need to trigger the second job from the first job via the Parameterized Build plugin -
see my answer here:
trigger other configuration and send current build status with Jenkins
The build status is not set until the job has finished running, so there is no easy way to push build status to a process triggered within the build itself. You could pull build status via the API, but this would have to be an externally triggered process due to the constraint mentioned above. Any reason you aren't using the built in email support or one of the excellent email extension plugins such as this one?

jenkins waiting for a event to happen

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.

Resources