简体   繁体   中英

Rundeck job to transfer a file to a remote node

I am trying to transfer a file through sftp in rundeck to a remote node.It fails the job execution with the error Failed: WrongParameter: sourcePath has to be a directory. my jod definition looks like this

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <dispatch>
      <excludePrecedence>true</excludePrecedence>
      <keepgoing>false</keepgoing>
      <rankOrder>ascending</rankOrder>
      <successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
      <threadcount>1</threadcount>
    </dispatch>
    <executionEnabled>true</executionEnabled>
    <id>8b7a993e-441d-4073-9e88-5ec801950a43</id>
    <loglevel>INFO</loglevel>
    <name>mytestjob2</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <nodefilters>
      <filter>172.105.34.168</filter>
    </nodefilters>
    <nodesSelectedByDefault>true</nodesSelectedByDefault>
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='true' strategy='node-first'>
      <command>
        <description>ftp file</description>
        <node-step-plugin type='copyfile'>
          <configuration>
            <entry key='destinationPath' value='/root/destination/' />
            <entry key='echo' value='true' />
            <entry key='recursive' value='true' />
            <entry key='sourcePath' value='/root/source/' />
          </configuration>
        </node-step-plugin>
      </command>
    </sequence>
    <uuid>8b7a993e-441d-4073-9e88-5ec801950a43</uuid>
  </job>
</joblist>

Can you tell me where am I going wrong ? how should I suppy the source directory to rundeck.

You must set the temp path in "Source Path" textbox with ${file.Upload} and set the file name on "Destination Path" textbox using "${file.Upload.fileName}" (like cp / mv UNIX command).

I leave a job definition that works (tested on Rundeck 3.3.1):

<joblist>
  <job>
    <context>
      <options preserveOrder='true'>
        <option name='Upload' type='file' />
      </options>
    </context>
    <defaultTab>output</defaultTab>
    <description></description>
    <dispatch>
      <excludePrecedence>true</excludePrecedence>
      <keepgoing>false</keepgoing>
      <rankOrder>ascending</rankOrder>
      <successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
      <threadcount>1</threadcount>
    </dispatch>
    <executionEnabled>true</executionEnabled>
    <id>6df7eb26-7f0f-46ed-bb60-cec9eb21b28b</id>
    <loglevel>INFO</loglevel>
    <name>UploadJob</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <nodefilters>
      <filter>name: remote</filter>
    </nodefilters>
    <nodesSelectedByDefault>true</nodesSelectedByDefault>
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <node-step-plugin type='copyfile'>
          <configuration>
            <entry key='destinationPath' value='/home/user/${file.Upload.fileName}' />
            <entry key='echo' value='true' />
            <entry key='recursive' value='false' />
            <entry key='sourcePath' value='${file.Upload}' />
          </configuration>
        </node-step-plugin>
      </command>
    </sequence>
    <uuid>6df7eb26-7f0f-46ed-bb60-cec9eb21b28b</uuid>
  </job>
</joblist>

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