この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

cancelDeploy()

まだ完了していないリリースをキャンセルします。

構文

1CancelDeployResult = metadatabinding.cancelDeploy(string id)

使用方法

deploy() 操作によって開始された組織内のリリースをキャンセルするには、cancelDeploy() 操作を使用します。これには、Force.com 移行ツールおよび Force.com IDE によって開始されたリリースが含まれます。リリースは、キュー内で開始待ちの場合や進行中の場合があります。この操作は、キャンセルするリリースの ID を取り、CancelDeployResult オブジェクトを返します。リリースがキュー内にあり、まだ開始していない場合、cancelDeploy() をコールすると即座にリリースがキャンセルされます。リリースがすでに開始し、進行中の場合、すぐにはキャンセルされないこともあるため、checkDeployStatus() をコールしてキャンセル状況をチェックする必要があります。

リリースをキャンセルするには、次の手順を実行します。

  1. キャンセルするリリースの ID を取得します。たとえば、deploy() コールで AsyncResult オブジェクトの id 項目から ID を取得できます。または、Salesforce ユーザインターフェースで、[設定] から [リリース状況] または [リリース] | [リリース状況] をクリックし、API で開始されたリリースの ID を確認しても ID を取得できます。
  2. cancelDeploy() コールを発行して、キャンセルプロセスを開始します。このコールは、CancelDeployResult オブジェクトを返します。
  3. 返された CancelDeployResult の done 項目の値をチェックします。done 項目値が true の場合、リリースはすでにキャンセルされており、作業は完了しています。done 項目値が false の場合、キャンセルは進行中であるため、次の手順に従ってキャンセル状況をチェックします。
    1. すでに取得したリリース ID を使用して checkDeployStatus() をコールします。
    2. 返された DeployResult オブジェクト内の status 項目をチェックします。状況が Canceling の場合、キャンセルは依然として進行中であるため、手順 a と b を繰り返します。状況が Canceled の場合、リリースはすでにキャンセルされており、作業は完了しています。

deploy() 操作は次の API 障害を発生させます。

「Invalid deploy ID」というメッセージを含む INVALID_ID_FIELD
指定された ID 引数が有効なリリースに対応していません。
「Deployment already completed」というメッセージを含む INVALID_ID_FIELD
指定されたリリースはすでに完了しています。

バージョン

API バージョン 30.0 以降で利用できます。

権限

クライアントアプリケーションは、「すべてのデータの編集」権限でログインしている必要があります。

引数

名前 型 説明
id string キャンセルするリリースの ID。

サンプルコード —Java

次のサンプルでは、リリースのキャンセル方法を示します。このサンプルは、特定のリリース ID を渡して cancelDeploy() をコールします。次に、キャンセルが完了したかどうかをチェックし、まだの場合は checkDeployStatus のコールをループします。

1swfobject.registerObject("clippy.codeblock-1", "9");public void cancelDeploy(String asyncId) throws Exception {
2    // Issue the deployment cancellation request  
3    CancelDeployResult result = metadataConnection.cancelDeploy(asyncId);
4    
5    // If the deployment cancellation completed, write a message to the output.
6    if (result.isDone()) {
7        System.out.println("Your deployment was canceled successfully!");
8    }
9    else {
10        // The deployment cancellation is still in progress, so get a new status 
11        DeployResult deployResult = metadataConnection.checkDeployStatus(asyncId, false);
12    
13        // Check whether the deployment is done. If not done, this means 
14        // that the cancellation is still in progress and the status is Canceling.        
15        while (!deployResult.isDone()) {
16            // Assert that the deployment status is Canceling
17            assert deployResult.getStatus() == DeployStatus.Canceling;
18            // Wait 2 seconds
19            Thread.sleep(2000);
20            // Get the deployment status again
21            deployResult = metadataConnection.checkDeployStatus(asyncId, false);
22        }
23        
24        // The deployment is done. Write the status to the output.
25        // (When the deployment is done, the cancellation should have completed
26        // and the status should be Canceled. However, in very rare cases,  
27        // the deployment can complete before it is canceled.) 
28        System.out.println("Final deploy status = >" + deployResult.getStatus());
29    }
30}