Class DeploymentResultServiceImpl
java.lang.Object
com.atlassian.bamboo.deployments.results.service.DeploymentResultServiceImpl
- All Implemented Interfaces:
DeploymentResultService
-
Constructor Summary
ConstructorDescriptionDeploymentResultServiceImpl
(BambooPermissionManager bambooPermissionManager, DeploymentResultDao deploymentResultDao, DeploymentVersionDao deploymentVersionDao, EnvironmentDao environmentDao, @NotNull EnvironmentService environmentService, @NotNull InternalEnvironmentService internalEnvironmentService, @NotNull VariableContextBaselineDao variableContextBaselineDao, @NotNull DeploymentsInProgressService deploymentsInProgressService, @NotNull TriggerManager triggerManager, com.opensymphony.xwork2.TextProvider textProvider) -
Method Summary
Modifier and TypeMethodDescriptionint
countDeploymentResultsForEnvironment
(long environmentId) Count deployment results for deployment.createDeploymentResult
(long environmentId, long deploymentVersionId, @NotNull VariableContext variableContext, @NotNull TriggerReason triggerReason) findEnvironmentIdsVersionWasDeployedOn
(long deploymentVersionId) @Nullable DeploymentResult
getDeploymentResult
(long deploymentResultId) Retrieve a specific deployment result.getDeploymentResultIdsForDeploymentVersionFinishedBefore
(long deploymentVersionId, @NotNull Date finishDate) Get ids of all deployment results for deployment version finished before given date.@NotNull List<DeploymentResult>
getDeploymentResultsByLifeCycleState
(Collection<LifeCycleState> lifeCycleStates) @NotNull List<DeploymentResult>
getDeploymentResultsForDeploymentVersion
(long deploymentVersionId) Get all deployment results for deployment version.@NotNull List<DeploymentResult>
getDeploymentResultsForDeploymentVersionAndEnvironment
(long deploymentVersionId, long environmentId) Get all deployment results for deployment versions that ran against the specified environment.@NotNull List<DeploymentResult>
getDeploymentResultsForDeploymentVersionFinishedBefore
(long deploymentVersionId, Date finishDate) Get all deployment results for deployment version finished before given date.@NotNull List<DeploymentResult>
getDeploymentResultsForEnvironment
(long environmentId) Get all deployment results for environment.@NotNull List<DeploymentResult>
getDeploymentResultsForEnvironment
(long environmentId, int offset, int maxResults) Get deployment results for environment.@NotNull List<DeploymentResult>
getDeploymentResultsForEnvironmentWithoutVariables
(long environmentId, int offset, int maxResults) Get deployment results for environment.getLastResultBefore
(@NotNull DeploymentResult deploymentResult) getLastResultInStatesBefore
(@NotNull DeploymentResult deploymentResult, @NotNull EnumSet<BuildState> buildStates) @Nullable DeploymentResult
getLatestDeploymentResult
(long environmentId, long deploymentVersionId) Retrieve a specific deployment result for an environment and version.@Nullable DeploymentResult
getLatestDeploymentResultForEnvironment
(long environmentId) Get the latest result that ran against an environment@NotNull List<EnvironmentStatus>
getLatestKnownDeploymentResultForEnvironments
(Iterable<? extends Environment> environments) Get the latest results that *actually* ran against a list of environments.@NotNull List<EnvironmentStatus>
getLatestKnownDeploymentResultForEnvironmentsInProject
(@NotNull DeploymentProject deploymentProject) Get the latest results that *actually* ran against a list of environments.getLatestStatusForAllEnvironments
(Map<Long, Environment> environmentsById, Map<Long, DeploymentProject> deploymentProjectsById) @NotNull Map<Long,
EnvironmentStatusForDashboard> getLatestStatusForEnvironments
(@NotNull List<Long> environmentIds) @NotNull List<DeploymentResult>
getResultsWhereDeploymentVersionIsDeployedNow
(List<Long> environmentsId, long deploymentVersionId) getRollbackVersion
(long environmentId) For a given environment find the version that existed on the environment prior to the last deployment.@Nullable DeploymentVersion
getRollbackVersion
(@NotNull DeploymentResult deploymentResult) For a given deployment result find the version that existed on the environment before that deployment.@NotNull List<EnvironmentStatusForAggregation>
getStatusesForAggregationByProject
(@NotNull DeploymentProject deploymentProject) @NotNull List<DeploymentResult>
getSuccessfulDeploymentResultsForEnvironment
(long environmentId, int offset, int maxResults) Get successful deployment results for environment.void
setExecutingAgent
(long deploymentResultId, long agentId) Set the agent that the deployment is executing on.void
updateDeploymentState
(long deploymentResultId, @NotNull BuildState deploymentState, Map<String, String> customData) Update the build state of the Deployment Resultvoid
updateLifeCycleState
(long deploymentResultId, @NotNull LifeCycleState lifeCycleState) Update lifecycle state of the DeploymentResult.void
updateLifeCycleState
(@NotNull DeploymentTimingPoint timingPoint, @NotNull LifeCycleState lifeCycleState) Update lifecycle state of the DeploymentResult
-
Constructor Details
-
DeploymentResultServiceImpl
public DeploymentResultServiceImpl(BambooPermissionManager bambooPermissionManager, DeploymentResultDao deploymentResultDao, DeploymentVersionDao deploymentVersionDao, EnvironmentDao environmentDao, @NotNull @NotNull EnvironmentService environmentService, @NotNull @NotNull InternalEnvironmentService internalEnvironmentService, @NotNull @NotNull VariableContextBaselineDao variableContextBaselineDao, @NotNull @NotNull DeploymentsInProgressService deploymentsInProgressService, @NotNull @NotNull TriggerManager triggerManager, com.opensymphony.xwork2.TextProvider textProvider)
-
-
Method Details
-
createDeploymentResult
public DeploymentResult createDeploymentResult(long environmentId, long deploymentVersionId, @NotNull @NotNull VariableContext variableContext, @NotNull @NotNull TriggerReason triggerReason) - Specified by:
createDeploymentResult
in interfaceDeploymentResultService
-
getDeploymentResult
Description copied from interface:DeploymentResultService
Retrieve a specific deployment result.- Specified by:
getDeploymentResult
in interfaceDeploymentResultService
- Parameters:
deploymentResultId
- of the result- Returns:
- deployment result with given id
-
getLatestDeploymentResult
@Nullable public @Nullable DeploymentResult getLatestDeploymentResult(long environmentId, long deploymentVersionId) Description copied from interface:DeploymentResultService
Retrieve a specific deployment result for an environment and version. There should only be one result per environment/version combination. Entirely possible it has not executed yet so will return null;- Specified by:
getLatestDeploymentResult
in interfaceDeploymentResultService
- Parameters:
environmentId
- of the environmentdeploymentVersionId
- of the version- Returns:
- deployment result for a version against an environment.
-
getLatestDeploymentResultForEnvironment
@Nullable public @Nullable DeploymentResult getLatestDeploymentResultForEnvironment(long environmentId) Description copied from interface:DeploymentResultService
Get the latest result that ran against an environment- Specified by:
getLatestDeploymentResultForEnvironment
in interfaceDeploymentResultService
- Parameters:
environmentId
- id of the environment- Returns:
- the latest result. Null if not run
-
getLatestKnownDeploymentResultForEnvironments
@NotNull public @NotNull List<EnvironmentStatus> getLatestKnownDeploymentResultForEnvironments(Iterable<? extends Environment> environments) Description copied from interface:DeploymentResultService
Get the latest results that *actually* ran against a list of environments. Any NOT_BUILT results are skipped, so you can see the state of that particular environment. Wraps the return into EnvironmentStatus'- Specified by:
getLatestKnownDeploymentResultForEnvironments
in interfaceDeploymentResultService
- Parameters:
environments
- we want to retrieve latest DeploymentResult- Returns:
- the List of EnvironmentStatus that contain latest results.
-
getLatestKnownDeploymentResultForEnvironmentsInProject
@NotNull public @NotNull List<EnvironmentStatus> getLatestKnownDeploymentResultForEnvironmentsInProject(@NotNull @NotNull DeploymentProject deploymentProject) Description copied from interface:DeploymentResultService
Get the latest results that *actually* ran against a list of environments. Any NOT_BUILT results are skipped, so you can see the state of that particular environment. Wraps the return into EnvironmentStatus' The variables contexts _are not fetched_- Specified by:
getLatestKnownDeploymentResultForEnvironmentsInProject
in interfaceDeploymentResultService
- Parameters:
deploymentProject
- we want to retrieve latest DeploymentResults for- Returns:
- the List of EnvironmentStatus that contain latest results.
-
getStatusesForAggregationByProject
@NotNull public @NotNull List<EnvironmentStatusForAggregation> getStatusesForAggregationByProject(@NotNull @NotNull DeploymentProject deploymentProject) - Specified by:
getStatusesForAggregationByProject
in interfaceDeploymentResultService
-
getDeploymentResultsForEnvironment
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsForEnvironment(long environmentId) Description copied from interface:DeploymentResultService
Get all deployment results for environment. Sorted by started date, newest first. todo pagination- Specified by:
getDeploymentResultsForEnvironment
in interfaceDeploymentResultService
- Parameters:
environmentId
- id of environment to get results from- Returns:
- List of deployment results
-
getDeploymentResultsForEnvironment
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsForEnvironment(long environmentId, int offset, int maxResults) Description copied from interface:DeploymentResultService
Get deployment results for environment. Sorted by started date, newest first, skips a number of results defined in 'offset' parameter, limits to 'maxResults'- Specified by:
getDeploymentResultsForEnvironment
in interfaceDeploymentResultService
- Parameters:
environmentId
- id of environment to get results from- Returns:
- List of deployment results
-
getDeploymentResultsForEnvironmentWithoutVariables
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsForEnvironmentWithoutVariables(long environmentId, int offset, int maxResults) Description copied from interface:DeploymentResultService
Get deployment results for environment. Sorted by started date, newest first, skips a number of results defined in 'offset' parameter, limits to 'maxResults'- Specified by:
getDeploymentResultsForEnvironmentWithoutVariables
in interfaceDeploymentResultService
- Parameters:
environmentId
- id of environment to get results from- Returns:
- List of deployment results
-
getSuccessfulDeploymentResultsForEnvironment
@NotNull public @NotNull List<DeploymentResult> getSuccessfulDeploymentResultsForEnvironment(long environmentId, int offset, int maxResults) Description copied from interface:DeploymentResultService
Get successful deployment results for environment. Sorted by started date, newest first, skips a number of results defined in 'offset' parameter, limits to 'maxResults'- Specified by:
getSuccessfulDeploymentResultsForEnvironment
in interfaceDeploymentResultService
- Parameters:
environmentId
- id of environment to get results from- Returns:
- List of successful deployment results
-
getDeploymentResultsForDeploymentVersion
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsForDeploymentVersion(long deploymentVersionId) Description copied from interface:DeploymentResultService
Get all deployment results for deployment version. Sorted by started date, newest first. This method could return significant sets of data and is a potential problem due to performance reasons- Specified by:
getDeploymentResultsForDeploymentVersion
in interfaceDeploymentResultService
- Parameters:
deploymentVersionId
- id of deployment version to get results from- Returns:
- List of deployment results sorted by started data (newest first)
-
getDeploymentResultsForDeploymentVersionAndEnvironment
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsForDeploymentVersionAndEnvironment(long deploymentVersionId, long environmentId) Description copied from interface:DeploymentResultService
Get all deployment results for deployment versions that ran against the specified environment.- Specified by:
getDeploymentResultsForDeploymentVersionAndEnvironment
in interfaceDeploymentResultService
- Parameters:
deploymentVersionId
- id of deployment versionenvironmentId
- id of environment- Returns:
- List of deployment results sorted by started date (newest first)
-
getDeploymentResultsForDeploymentVersionFinishedBefore
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsForDeploymentVersionFinishedBefore(long deploymentVersionId, Date finishDate) Description copied from interface:DeploymentResultService
Get all deployment results for deployment version finished before given date. Sorted by started date, newest first. This method could return significant sets of data and is a potential problem due to performance reasons- Specified by:
getDeploymentResultsForDeploymentVersionFinishedBefore
in interfaceDeploymentResultService
- Parameters:
deploymentVersionId
- id of deployment version to get results fromfinishDate
- only select results finished before this date- Returns:
- List of deployment results sorted by started data (newest first)
-
getDeploymentResultIdsForDeploymentVersionFinishedBefore
@NotNull public @NotNull List<Long> getDeploymentResultIdsForDeploymentVersionFinishedBefore(long deploymentVersionId, @NotNull @NotNull Date finishDate) Description copied from interface:DeploymentResultService
Get ids of all deployment results for deployment version finished before given date. Sorted by started date, oldest first.- Specified by:
getDeploymentResultIdsForDeploymentVersionFinishedBefore
in interfaceDeploymentResultService
- Parameters:
deploymentVersionId
- id of deployment version to get results fromfinishDate
- only select results finished before this date- Returns:
- List of deployment results sorted by started data (oldest first)
-
countDeploymentResultsForEnvironment
public int countDeploymentResultsForEnvironment(long environmentId) Description copied from interface:DeploymentResultService
Count deployment results for deployment.- Specified by:
countDeploymentResultsForEnvironment
in interfaceDeploymentResultService
- Returns:
-
getDeploymentResultsByLifeCycleState
@NotNull public @NotNull List<DeploymentResult> getDeploymentResultsByLifeCycleState(Collection<LifeCycleState> lifeCycleStates) - Specified by:
getDeploymentResultsByLifeCycleState
in interfaceDeploymentResultService
-
getRollbackVersion
Description copied from interface:DeploymentResultService
For a given environment find the version that existed on the environment prior to the last deployment. This is the version that you would "Roll back" to in the case of problems.- Specified by:
getRollbackVersion
in interfaceDeploymentResultService
- Parameters:
environmentId
- to find rollback version for.- Returns:
- the version that is considered the rollback version for this environment
-
getRollbackVersion
@Nullable public @Nullable DeploymentVersion getRollbackVersion(@NotNull @NotNull DeploymentResult deploymentResult) Description copied from interface:DeploymentResultService
For a given deployment result find the version that existed on the environment before that deployment.- Specified by:
getRollbackVersion
in interfaceDeploymentResultService
- Parameters:
deploymentResult
- deployment result that was deployed at some time on some environment- Returns:
- deployment that was previously on same environment
-
updateDeploymentState
public void updateDeploymentState(long deploymentResultId, @NotNull @NotNull BuildState deploymentState, Map<String, String> customData) Description copied from interface:DeploymentResultService
Update the build state of the Deployment Result- Specified by:
updateDeploymentState
in interfaceDeploymentResultService
- Parameters:
deploymentResultId
- if of result to updatedeploymentState
- new value of the build state to save
-
updateLifeCycleState
public void updateLifeCycleState(long deploymentResultId, @NotNull @NotNull LifeCycleState lifeCycleState) Description copied from interface:DeploymentResultService
Update lifecycle state of the DeploymentResult. This method expects only PENDING and NOT_BUILD lifeCycleState.- Specified by:
updateLifeCycleState
in interfaceDeploymentResultService
- Parameters:
deploymentResultId
- id of DeploymentResultlifeCycleState
- lifecycle state to be set
-
updateLifeCycleState
public void updateLifeCycleState(@NotNull @NotNull DeploymentTimingPoint timingPoint, @NotNull @NotNull LifeCycleState lifeCycleState) Description copied from interface:DeploymentResultService
Update lifecycle state of the DeploymentResult- Specified by:
updateLifeCycleState
in interfaceDeploymentResultService
- Parameters:
timingPoint
- deployment timing pointlifeCycleState
- lifecycle state to be set
-
setExecutingAgent
public void setExecutingAgent(long deploymentResultId, long agentId) Description copied from interface:DeploymentResultService
Set the agent that the deployment is executing on.- Specified by:
setExecutingAgent
in interfaceDeploymentResultService
- Parameters:
deploymentResultId
- id of the deployment resultagentId
- if of the agent
-
findEnvironmentIdsVersionWasDeployedOn
- Specified by:
findEnvironmentIdsVersionWasDeployedOn
in interfaceDeploymentResultService
- Returns:
- ids of all environments a version was ever deployed on
-
getLastResultBefore
- Specified by:
getLastResultBefore
in interfaceDeploymentResultService
- Returns:
- result of the last deployment performed on an environment before given result
-
getLastResultInStatesBefore
public DeploymentResult getLastResultInStatesBefore(@NotNull @NotNull DeploymentResult deploymentResult, @NotNull @NotNull EnumSet<BuildState> buildStates) - Specified by:
getLastResultInStatesBefore
in interfaceDeploymentResultService
- Returns:
- result of the last deployment performed on an environment before given result in one of given states
-
getLatestStatusForAllEnvironments
public Map<Long,EnvironmentStatus> getLatestStatusForAllEnvironments(Map<Long, Environment> environmentsById, Map<Long, DeploymentProject> deploymentProjectsById) - Specified by:
getLatestStatusForAllEnvironments
in interfaceDeploymentResultService
- Parameters:
environmentsById
- pass all visible environments. Any environments not passed will not have results returned. This can technically be used to retrieve deployment results for a subset of environments but it's only efficient for significant sets. By definition this should not contain any environments without visible projects.deploymentProjectsById
- All visible deployment projects.- Returns:
- the latest environment status for each environment in the system as a map of environment Id to EnvironmentStatus. Environments that have not been deployed will have a status with no result. Note that this is potentially a very slow operation and should be called only when most deployment results will be required.
-
getLatestStatusForEnvironments
@NotNull public @NotNull Map<Long,EnvironmentStatusForDashboard> getLatestStatusForEnvironments(@NotNull @NotNull List<Long> environmentIds) throws AccessDeniedException - Specified by:
getLatestStatusForEnvironments
in interfaceDeploymentResultService
- Returns:
- the latest environment status for environments ids passes as the first argument as a map of environment Id to EnvironmentStatus. Environments that have not been deployed will have a status with no result.
- Throws:
AccessDeniedException
- if user has no access to requested environment.
-
getResultsWhereDeploymentVersionIsDeployedNow
@NotNull public @NotNull List<DeploymentResult> getResultsWhereDeploymentVersionIsDeployedNow(List<Long> environmentsId, long deploymentVersionId) - Specified by:
getResultsWhereDeploymentVersionIsDeployedNow
in interfaceDeploymentResultService
- Parameters:
environmentsId
- list of environments to check- Returns:
- list of deployment results that are now deployed on given environments
-