Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: Invoking REST API (or wget) at end of Jenkins job without writing any script

Tags:

jenkins

I thought this should be simple, but I am not able to find any Jenkins plugin which would simply let me call a REST GET API (equivalent of wget URL) when the job is finished. Am I missing something here? As I certainly don't want to write a new plugin for this simple task.

I have scanned through all the plugins and the only interesting one are:

  • Post build task
  • Groovy Postbuild Plugin

But in my case, I don't have access to Jenkins' file system, so I can't write a post-build script to do this job, or neither can I install Groovy on that machine.

Also, Jenkins is running on a Windows Server 2008 machine.

like image 464
Hemant Avatar asked Mar 22 '14 00:03

Hemant


People also ask

Can Jenkins call REST API?

Jenkins provides rich set of REST based APIs. The REST API feature can be enabled per Job basis. To enable REST API trigger for a Job, Navigate to Your JobName ->Configure -> Build triggers TAB and Check on 'Trigger build remotely'.

How do I access REST API Jenkins?

The simplest way to access Jenkins REST API is to gather the User Token which is available by selecting your User and clicking on Configure. Now you will use the token as parameter for your authentication.

How can we trigger Jenkins job from outside of Jenkins?

Create a remote Jenkins build trigger in three stepsCreate a Jenkins build job and enable the Trigger builds remotely checkbox. Provide an authentication token; This can be any text string of your choice. Invoke the Jenkins build URL to remotely trigger the build job.


1 Answers

There is a plugin that allows to make an HTTP request (GET and POST) as a build step.

There is also a plugin that allows any build step to be used in post-build actions.

Use both and you get what you are asking for.

To be able to use any build step as a post-build action, you need to enable this in the settings. Go to: Jenkins → Manage JenkinsConfigure SystemFlexible Push and switch the dropdown menu to "Any build step".

like image 161
Slav Avatar answered Oct 04 '22 09:10

Slav