Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chtrembl committed Sep 27, 2024
1 parent a5cea9c commit 59efd9e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,15 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
dpResponse = this.azureDemo.getAzureResources(this.at1, azurePetStoreSessionInfo);
}
break;
case DISPLAY_ADO_PIPELINES_DEMO:
if (azurePetStoreSessionInfo != null) {
return turnContext.sendActivity(
MessageFactory.text("There is 1 Azure DevOps Pipeline, azure-petstoreautomation-regression-tests")).thenApply(sendResult -> null);
}
case EXECUTE_ADO_PIPELINES_DEMO:
if (azurePetStoreSessionInfo != null) {
dpResponse = this.azureDemo.executeDevopsPipeline(azurePetStoreSessionInfo);
//typically if this wasnt a quick demo we would find the right pipeline to execute based on verbal/text command
dpResponse = this.azureDemo.executeDevopsPipeline(at2, azurePetStoreSessionInfo);
}
break;
case UPDATE_SHOPPING_CART:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,44 @@ public DPResponse getAzureResources(String at1, AzurePetStoreSessionInfo azurePe
}

@Override
public DPResponse executeDevopsPipeline(AzurePetStoreSessionInfo azurePetStoreSessionInfo) {
public DPResponse executeDevopsPipeline(String at2, AzurePetStoreSessionInfo azurePetStoreSessionInfo) {
LOGGER.info("executeDevopsPipeline invoked, text: {}", azurePetStoreSessionInfo.getNewText());

DPResponse dpResponse = new DPResponse();
dpResponse.setDpResponseText("I'm sorry, I wasn't able to execute the DevOps pipeline.");
try {
String adoResponse = this.adoClient.post()
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + at2)
.bodyValue("{\n" + //
" \"resources\": {\n" + //
" \"repositories\": {\n" + //
" \"self\": {\n" + //
" \"refName\": \"refs/heads/main\"\n" + //
" }\n" + //
" }\n" + //
" }\n" + //
"}")
.retrieve()
.bodyToMono(String.class)
.block();

dpResponse.setDpResponseText("Azure DevOps Pipeline executed successfully");


LOGGER.info("executeDevopsPipeline response for text ");
}
catch (WebClientException webClientException) {
LOGGER.error("Error parsing getAzureResources response ", webClientException);
if(webClientException.getMessage().contains("429"))
{
dpResponse.setRateLimitExceeded(true);
}

dpResponse.setDpResponseText("I'm sorry, I wasn't able to execute the Azure DevOps Pipeline, check at.");
}
catch (Exception e) {
LOGGER.error("Error parsing executeDevopsPipeline response azure " + azurePetStoreSessionInfo != null ? "session id: " + azurePetStoreSessionInfo.getId() + " id: " + azurePetStoreSessionInfo.getId() : "session id: null", e);
}
return dpResponse;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

public interface IAzureDemo {
public DPResponse getAzureResources(String at1, AzurePetStoreSessionInfo azurePetStoreSessionInfo);
public DPResponse executeDevopsPipeline(AzurePetStoreSessionInfo azurePetStoreSessionInfo);
public DPResponse executeDevopsPipeline(String at2, AzurePetStoreSessionInfo azurePetStoreSessionInfo);
}

0 comments on commit 59efd9e

Please sign in to comment.