PHP code example of rundeck / rundeck-client
1. Go to this page and download the library: Download rundeck/rundeck-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rundeck / rundeck-client example snippets
use Rundeck\RundeckClient;
// Init client, user/pass is optional
$rd = new RundeckClient('http://localhost:4440', 'admin', 'admin');
// returns array of Rundeck\Api\Project
$projects = $rd->getProjects();
// returns array of Rundeck\Api\Job
$jobs = $rd->getJobs($projects[0]->getName()); // By Project Name
// backup/export project jobs
foreach ($projects as $project) {
@mkdir(__DIR__.'/xml/'.$project);
$xml = $rd->exportJobs($project);
file_put_contents('/path-to-jobs/'.$project.'/jobs.xml', $xml);
}
// create project and import jobs
$projectName = 'Hello World';
$rd->deleteProject($projectName); //