maven - Creating a scheduled task in Nexus via the REST API -


one of parameters schedules rest api endpoint of nexus provides schedule. defines frequency created task executed. available options in ui are: manual, once, hourly, daily, weekly, monthly , advanced.

however, when try create scheduled task via rest api , specify schedule different manual, 500 status code in reply (and means server encountered unexpected condition did not allow fulfil request). guess i'm missing additional parameters, because, via nexus ui, see choosing (for instance) hourly schedule presents few options (e.g. start date , start time).

as explained in api's documentation, schedulesend point provides way pass parameters in key, value pairs (via properties element).

my question 2 fold:

  1. is assumption missing parameters correct?
  2. if so, correct formats key, value pairs each of possible schedules?

disclaimer: following works nexus 2.14. think nexus 3.0 doesn't have rest-api , 3.1, don't know if has 1 or no.

so,
way of figuring out data required scheduled task first http on http://<your-repo>/nexus/service/local/schedules return scheduled tasks have. among other infos name , type, output contains, respective ids.

(make sure first created via ui task similar 1 going create via rest).

then, doing on http://<your-repo>/nexus/service/local/schedules/<id> scheduled-task-id interested in, stuffs , parameters need.

in case, wanted create scheduled task removes old release artifacts , data needed post nexus looks this:

<?xml version="1.0" encoding="utf-8"?> <scheduled-task>   <data>     <enabled>true</enabled>     <name>remove releases 123-releases-repo</name>     <typeid>releaseremovertask</typeid>     <schedule>daily</schedule> <!-- startdate timestamp, in millis, required avoid nasty numberformatexception -->     <startdate>1234567</startdate>     <recurringtime>03:00</recurringtime>     <properties>       <scheduled-task-property>         <key>numberofversionstokeep</key>         <value>1</value>       </scheduled-task-property>       <scheduled-task-property>         <key>indexbackend</key>         <value>false</value>       </scheduled-task-property>       <scheduled-task-property>         <key>repositoryid</key>         <value>123-releases-repo</value>       </scheduled-task-property>     </properties>   </data> </scheduled-task> 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -