Is there any script or plugin so that I can take Jenkins node offline automatically if the job passes.
Or if i explicitly give choice parameter to take node offline after current build.
I mentioned before an API for disconnecting a node: see more at "Monitor and Restart Offline Slaves".
That means you can add a post-build action, which would call this api though curl.
Related
As a Jenkins beginner, I am seeking the best way to abort downstream Jenkins job when a user hits Submit button on web. The job could either be in a queue or running when user hits 'Stop'.
While searching for possible options, I saw that Jenkins supports REST APIs as well as one can use curl but for that one needs to know the state of downstream job whether it's queued/running.
(Jenkins would need authentication as access is restricted, not sure how tokens work too)
This is still a pending request: JENKINS-11257
jenkinsci/parameterized-trigger-plugin Pull-Request 104 could be a solution if you can modify and rebuilt your own Jenkins Parameterized Trigger Plugin
This python script could help
you can try and experiment with Jenkins: how to stop downstream projects when upstream is aborted and its "kill" nuclear option.
(I'm new to Jenkins and curl, so please forgive any imprecision below.)
I am running a Jenkins job on one network that sends a curl command to a second network that is used to start a Jenkins job on that second network.
Sometimes I have to log onto that second network and restart the job using the Rebuild button provided by the Rebuild plugin.
I need to know how to determine whether the job on the second network was started by the original curl command or restarted via the Rebuild plugin, without the user having to do anything but restart the job with the same parameters.
I could use an extra boolean-parameter in the job on the second network that can be set to true by the curl command and to false when using the Rebuild button, but that requires the user to manually change the value of that parameter. I don't want the user to have to do that.
I think this only possible by using different users, or lets say an own user for the remote invocation. Anything more informative would have to be done manually for instance by an own paramter for the job. Normally jobs are started by developers, schedulers, hooks or by other jobs on the same instance. If triggered remotelly the job is triggered by a user as well, without authentication its the anonymus user who triggers the job.
Do you know the Jenkins CLI, could replace your curl commands?
https://jenkins.io/doc/book/managing/cli/
I need to trigger build in jenkins which is in cloud (AZURE) by a command passed in HipChat Integration.
The thing that you are looking for is often referred to as ChatOps. There are couple of tools that allow you to do such thing, which is effectively a program joining the chat room (the "bot") and waiting for commands.
The list of tools includes Hubot and StackStorm, which then call Jenkins API to trigger the job. An adapter for StackStorm exists here.
How can I get Jenkins to handle node connection failures?
Right now, if a slave drops the connection to the master, all the builds running on that node fail. Ideally, these would just be rescheduled.
Has someone already addressed this issue?
Do I need to write my own plugin for this? If so, where would I "extend" Jenkins functionality?
See the Post build task plugin:
This plugin allows the user to execute a shell/batch task depending on the build log output.
See http://<Your Jenkins>/job/<Your job's name>/api/:
Perform a build
To programmatically schedule a new build, post to this URL [http://<Your Jenkins>/job/<Your job's name>/build]
How can I stop Jenkins build for specific job?
I am looking for REST API
I did not find such in documentation
EDIT
The tricky part is that I need to fetch the running build ID somehow so I can send
http://HUDSON_URL/job/JOBNAME/BUILDNUMBER/stop