简体   繁体   中英

How to create a job in Rundeck that triggers REST URL?

There is a REST endpoint doing some automation work. I need to run it from Rundeck as a JOB. Is it possible to do so.

Sure, for example, you can use the HTTP Workflow Step Plugin plugin to call any API REST URL in the same way of cURL. Or just call directly (using cURL on command step or inline-script/script steps).

I leave this job definition example (with the HTTP Workflow Step plugin way) that uses the httpbin testing service:

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>f953870e-efbb-4144-bea4-7432c4733710</id>
    <loglevel>INFO</loglevel>
    <name>HelloWorld</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <step-plugin type='edu.ohio.ais.rundeck.HttpWorkflowStepPlugin'>
          <configuration>
            <entry key='authentication' value='None' />
            <entry key='checkResponseCode' value='false' />
            <entry key='method' value='POST' />
            <entry key='printResponse' value='true' />
            <entry key='printResponseToFile' value='false' />
            <entry key='proxySettings' value='false' />
            <entry key='remoteUrl' value='https://httpbin.org/anything' />
            <entry key='sslVerify' value='false' />
            <entry key='timeout' value='30000' />
          </configuration>
        </step-plugin>
      </command>
    </sequence>
    <uuid>f953870e-efbb-4144-bea4-7432c4733710</uuid>
  </job>
</joblist>

Here the same thing but using script step:

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>908fae13-1282-4584-b8bf-2f626c605cfe</id>
    <loglevel>INFO</loglevel>
    <name>HelloWorld</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[curl -s -X POST "https://httpbin.org/anything" -H  "accept: application/json"]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/sh</scriptinterpreter>
      </command>
    </sequence>
    <uuid>908fae13-1282-4584-b8bf-2f626c605cfe</uuid>
  </job>
</joblist>

And here the result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM