go-octopusdeploy icon indicating copy to clipboard operation
go-octopusdeploy copied to clipboard

[BUG] Deployment.FailureEncountered Does Not Populate as Expected (Always False)

Open kurtislamb opened this issue 1 month ago • 0 comments

Description When calling Deployments.GetDeployment the returned data incorrectly shows FailureEncountered as False even if the deployment indeed failed.

Steps To Reproduce 1.Init a Client 2.Create a projects.Project struct eg octopusProjectData.project in below code 3.Use code below to get all releases for a project then iterate through each release, then iterate through each deployment

releaseInfo, err := client.Projects.GetReleases(octopusProjectData.project)
	if err != nil {
		return latestSuccessfulRelease, fmt.Errorf("failed to lookup Release data: %w", err)
	}

	for _, release := range releaseInfo {
		log.Println("Release Version:", release.Version)
		deployments, err := client.Deployments.GetDeployments(release)
		for _, deployment := range deployments.Items {
                        log.Println(release.Version)
			log.Println(deployment.ID)
			log.Println(deployment.FailureEncountered, "\n")
		}
	}

Expected Behavior If a deployment for a release has failed, I would expect FailureEncountered to return true, so we can then disregard this deployment.

First 2 should show as True (A Failure was Encountered)

2025/01/03 08:46:45 KL-2025.0.3
2025/01/03 08:46:45 Deployments-1478
2025/01/03 08:46:45 true

2025/01/03 08:46:45 KL-2025.0.2
2025/01/03 08:46:45 Deployments-1477
2025/01/03 08:46:45 true

2025/01/03 08:46:45 KL-2025.0.1
2025/01/03 08:46:45 Deployments-1474
2025/01/03 08:46:45 false 

Any Logs and/or Other Supporting Information

Output From Octopus Deploy, I would expect .0.3 and .0.2 to return as failed image

Output from GO

2025/01/03 08:46:45 KL-2025.0.3
2025/01/03 08:46:45 Deployments-1478
2025/01/03 08:46:45 false 

2025/01/03 08:46:45 KL-2025.0.2
2025/01/03 08:46:45 Deployments-1477
2025/01/03 08:46:45 false 

2025/01/03 08:46:45 KL-2025.0.1
2025/01/03 08:46:45 Deployments-1474
2025/01/03 08:46:45 false 

Environment and/or Versions

  • Octopus Server Version: Octopus 2025.1 - Cloud
  • Go Version: go1.23.0 linux/amd64

Additional Context The approach of the above code is to find the last Deployment for a Project, iterating through releases and their deployments.

kurtislamb avatar Jan 03 '25 08:01 kurtislamb