类com.amazonaws.services.codedeploy.AmazonCodeDeploy源码实例Demo

下面列出了怎么用com.amazonaws.services.codedeploy.AmazonCodeDeploy的API类实例代码及写法,或者点击链接到github查看源代码。


@Override
protected Void run() throws Exception {
	TaskListener listener = this.getContext().get(TaskListener.class);
	AmazonCodeDeploy client = AWSClientFactory.create(AmazonCodeDeployClientBuilder.standard(), this.getContext());

	listener.getLogger().format("Checking Deployment(%s) status", this.deploymentId);

	while (true) {
		GetDeploymentRequest getDeploymentRequest = new GetDeploymentRequest().withDeploymentId(this.deploymentId);
		GetDeploymentResult deployment = client.getDeployment(getDeploymentRequest);
		String deploymentStatus = deployment.getDeploymentInfo().getStatus();

		listener.getLogger().format("DeploymentStatus(%s)", deploymentStatus);

		if (SUCCEEDED_STATUS.equals(deploymentStatus)) {
			listener.getLogger().println("Deployment completed successfully");
			return null;
		} else if (FAILED_STATUS.equals(deploymentStatus)) {
			listener.getLogger().println("Deployment completed in error");
			String errorMessage = deployment.getDeploymentInfo().getErrorInformation().getMessage();
			throw new Exception("Deployment Failed: " + errorMessage);
		} else if (STOPPED_STATUS.equals(deploymentStatus)) {
			listener.getLogger().println("Deployment was stopped");
			throw new Exception("Deployment was stopped");
		} else {
			listener.getLogger().println("Deployment still in progress... sleeping");
			try {
				Thread.sleep(POLLING_INTERVAL);
			} catch (InterruptedException e) {
				//
			}
		}

	}

}
 
源代码2 项目: herd-mdl   文件: CodeDeployUtils.java

/**
 * Waits for a given deployment to succeed (or fail).
 *
 * @param deploymentId: String. The specified deployment's id.
 */
public static void waitForMostRecentDeployment(String deploymentId) {

  LOGGER.debug("Waiting on deployment with id: \'{}\'", deploymentId);

  AmazonCodeDeploy codeDeployClient = AmazonCodeDeployClientBuilder.standard()
      .withRegion(Regions.US_EAST_1).build();

  GetDeploymentRequest getDeploymentRequest = new GetDeploymentRequest();
  getDeploymentRequest.setDeploymentId(deploymentId);

  Waiter<GetDeploymentRequest> waiter = codeDeployClient.waiters().deploymentSuccessful();
  try {

    waiter.run(new WaiterParameters<>(getDeploymentRequest));
    LOGGER.info("Deployment was successful.");

  } catch (WaiterUnrecoverableException | WaiterTimedOutException e) {
    LOGGER.error("Deployment with id: {} was unsuccessful.", deploymentId);
  }

}
 

@Bean
public AmazonCodeDeploy codeDeploy() {
    final AmazonCodeDeploy client = new AmazonCodeDeployClient();
    client.setRegion(region);
    return client;
}
 
 类所在包
 类方法
 同包方法