$artifact_id = $argv[3]; $summary = $argv[4]; $file = $argv[5]; $filesize = filesize($file); $filename = basename($file); $filetype = system('file -b --mime-type ' . escapeshellarg($file)); // Connecting to the soap's tracker client $soapTracker = new SoapClient($serverURL . '/plugins/tracker/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE)); //executing method updateArtefact // creating temporary file $uuid = $soapTracker->createTemporaryAttachment($requesterSessionHash); $value = array(array('field_name' => 'summary', 'field_label' => '', 'field_value' => array('value' => $summary)), array('field_name' => 'attachment', 'field_label' => '', 'field_value' => array('file_info' => array(array('id' => $uuid, 'submitted_by' => 0, 'description' => 'description', 'filename' => $filename, 'filesize' => $filesize, 'filetype' => $filetype, 'action' => ''))))); $total_written = 0; $offset = 0; $chunk_size = 20000; $is_last_chunk = false; while ($chunk = file_get_contents($file, false, null, $offset, $chunk_size)) { $chunk_length = strlen($chunk); $is_last_chunk = $chunk_length < $chunk_size; $chunk_written = $soapTracker->appendTemporaryAttachmentChunk($requesterSessionHash, $uuid, base64_encode($chunk)); if ($chunk_written !== $chunk_length) { var_dump("Warning: chunk not completely written on server"); } $total_written += $chunk_written; $offset += $chunk_size; } if ($total_written == strlen(file_get_contents($file))) { var_dump("File successfully uploaded"); } $response = $soapTracker->updateArtifact($requesterSessionHash, $project_id, $tracker_id, $artifact_id, $value, 'One comment', 0); var_dump($response);
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Tuleap. If not, see <http://www.gnu.org/licenses/>. */ // format : project_id tracker_id artifact_id value [comment] if ($argc < 2) { die("Usage: " . $argv[0] . " artifact_id" . PHP_EOL); } $serverURL = getenv('TULEAP_SERVER') ? getenv('TULEAP_SERVER') : 'http://sonde.cro.enalean.com'; $login = getenv('TULEAP_USER') ? getenv('TULEAP_USER') : 'testman'; $password = getenv('TULEAP_PASSWORD') ? getenv('TULEAP_PASSWORD') : 'testpwd'; $soapLogin = new SoapClient($serverURL . '/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE)); // Establish connection to the server $requesterSessionHash = $soapLogin->login($login, $password)->session_hash; //save values $project_id = 0; $tracker_id = 0; $artifact_id = $argv[1]; $value = array(array('field_name' => 'list_field', 'field_label' => '', 'field_value' => array('bind_value' => array(array('bind_value_id' => '106', 'bind_value_label' => 'roger')))), array('field_name' => 'summary_1', 'field_label' => '', 'field_value' => array('value' => 'my new summary'))); // Connecting to the soap's tracker client $soapTracker = new SoapClient($serverURL . '/plugins/tracker/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE)); //executing method updateArtefact if ($argc == 7) { $comment = $argv[5]; $comment_type = $argv[6]; $response = $soapTracker->updateArtifact($requesterSessionHash, $project_id, $tracker_id, $artifact_id, $value, $comment, $comment_type); } else { $response = $soapTracker->updateArtifact($requesterSessionHash, $project_id, $tracker_id, $artifact_id, $value); } var_dump($response);
<?php /////////////////////////////////////// // Configuration part $test_server = 'http://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']; $login = '******'; $password = '******'; $group_id = 101; $tracker_id = 123; $artifact_id = 76; $field_values = array(array('artifact_id' => 76, 'field_id' => 847, 'field_label' => '', 'field_value' => '2009-12-05'), array('artifact_id' => 76, 'field_id' => 846, 'field_label' => '', 'field_value' => 103), array('artifact_id' => 76, 'field_id' => 850, 'field_label' => '', 'field_value' => 44.5)); $follow_up_comment = 'Updated some fields from SOAP API'; /////////////////////////////////////// try { $client_tracker_v5 = new SoapClient($test_server . '/plugins/tracker/soap/wsdl?wsdl', array('trace' => 1, 'exceptions' => 0, 'soap_version' => SOAP_1_1, 'cache_wsdl' => 0)); $client = new SoapClient($test_server . '/soap/codendi.wsdl.php?wsdl', array('trace' => 1, 'exceptions' => 0, 'soap_version' => SOAP_1_1, 'cache_wsdl' => 0)); $session = $client->login($login, $password); $session_hash = $session->session_hash; $user_id = $session->user_id; echo 'User ' . $login . ' (user_id=' . $user_id . ') is logged with session hash = ' . $session_hash . '<br>'; echo '<h1>Update artifact # ' . $artifact_id . ' of tracker ' . $tracker_id . ' in project ' . $group_id . '</h1>'; echo '<h3>function updateArtifact</h3>'; $ok = $client_tracker_v5->updateArtifact($session_hash, $group_id, $tracker_id, $artifact_id, $field_values, $follow_up_comment); if ($ok) { var_dump("Artifact updated."); } else { var_dump("Artifact not updated: Error."); } } catch (SoapFault $fault) { var_dump($fault); }