Interface EnvironmentService
- All Known Implementing Classes:
EnvironmentServiceImpl
public interface EnvironmentService
Provides services and functionality around Environments. All objects returned/inputted are immutable.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull EnvironmentaddEnvironment(long deploymentProjectId, @Nullable String name, @Nullable String description) Creates a new environment in the specified deployment project.@NotNull EnvironmentaddEnvironment(long deploymentProjectId, @Nullable String name, @Nullable String description, @Nullable ReleaseApprovalPrerequisite environmentPrerequisites) Creates a new environment in the specified deployment project.voidaddNotification(long environmentId, @NotNull NotificationRule newRule) Adds a new notification to the environment notificationscloneEnvironment(long deploymentProjectId, long environmentId, @Nullable String name, @Nullable String description) Create new environment as a clone of existing onecloneEnvironment(long deploymentProjectId, long environmentId, @Nullable String name, @Nullable String description, @NotNull Map<String, String> oldAndClonedEnvironmentIds) Create new environment as a clone of existing one and if necessary update triggers' configurationlongcountAll()@NotNull EnvironmentcreateImmutableEnvironment(@NotNull MutableEnvironment environment) Converts mutable environment to immutable.@NotNull EnvironmentcreateOperationsAwareImmutableEnvironment(@NotNull MutableEnvironment environment) Create operation aware immutable environmentvoiddeleteNotification(long environmentId, long notificationId) Removes notification from the environment's notification set.@NotNull EnvironmenteditEnvironment(long environmentId, String name, String description) Edit the details of an existing environment@NotNull EnvironmenteditEnvironment(long environmentId, String name, String description, @Nullable ReleaseApprovalPrerequisite environmentPrerequisites) Edit the details of an existing environment@Nullable EnvironmentfindEnvironmentByName(long deploymentProjectId, String name) Find environment with specified name in a deployment project@NotNull Set<RequirementDeploymentMapping>findEnvironmentsByRequirementKey(@NotNull String requirementKey) Find environments which rely on requirementKey@NotNull Iterable<Environment>Retrieve allEnvironmentdefined in the system.@NotNull Collection<Environment>Retrieve allEnvironmentdefined in the system.@NotNull Iterable<Environment>Deprecated.getAllEnvironmentsNoUserContext(int firstResult, int maxResults) Deprecated.since 9.3, avoid due to poor performance, usegetAllInternalEnvironmentsNoUserContext(int, int)@NotNull Iterable<InternalEnvironment>getAllInternalEnvironmentsNoUserContext(int firstResult, int maxResults) Retrieve allEnvironmentdefined in the system without filling in operations permitted for the user.@Nullable EnvironmentgetEnvironment(long environmentId) Get specific environment by ID.intintgetEnvironmentCountForProject(DeploymentProject deploymentProject) Create environment decorator function object.getEnvironmentRepositoryLinksForRepository(long repositoryId) @Nullable RequirementSetgetEnvironmentRequirementSet(long environmentId) Retrieve Agent Requirement set for environment, if environment with id exists.@NotNull List<Environment>getEnvironmentsForDeploymentProject(long deploymentProjectId) Get all environments for a particular deployment project.getEnvironmentsMatchingCapabilities(int start, int limit, @Nullable String filter, @NotNull ReadOnlyCapabilitySet agentCapabilities) Deprecated.9.2, the method does not take into account the agent's assignments, usegetEnvironmentsMatchingCapabilities(int, int, String, ReadOnlyCapabilitySet, Iterable)insteadgetEnvironmentsMatchingCapabilities(int start, int limit, @Nullable String filter, @NotNull ReadOnlyCapabilitySet agentCapabilities, @NotNull Iterable<AgentAssignmentService.AgentAssignmentExecutor> agentAssignmentExecutors) Provide a paginated list of minimal information about deployment environments matching agent capabilities.@NotNull List<EnvironmentStub>getEnvironmentStubsForDeploymentProject(long deploymentProjectId) Get all environment stubs for a particular deployment project.getEnvironmentsUsingRepository(long repositoryId) Deprecated.since 5.13, usegetEnvironmentRepositoryLinksForRepository(long)getEnvironmentsUsingRepositoryDataEntity(long repositoryId) TODO 6.0 rename to getEnvironmentsUsingRepository@Nullable EnvironmentgetEnvironmentUnrestricted(long environmentId) Get specific environment by ID.@Nullable NotificationSetgetNotificationSet(long environmentId) Retrieve notification set for environment, if environment with id exists.@NotNull PaginatedEnvironmentsForDashboardgetPaginatedEnvironmentsForDeploymentProject(long deploymentProjectId, int start, int limit, @Nullable String filter) Get paginated environments for a particular deployment project ordered by position.@NotNull List<PlanRepositoryDefinition>getPlanRepositoryDefinitionsForEnvironment(@NotNull Environment environment) Deprecated.@NotNull List<PlanRepositoryDefinition>getPlanRepositoryDefinitionsForEnvironment(@NotNull InternalEnvironment environment) Retrieves all repositories used in environment source checkout tasks@NotNull List<RepositoryDefinition>getRepositoryDefinitionsForEnvironment(@NotNull Environment environment) Deprecated.moveEnvironment(MoveEnvironmentStrategy moveEnvironmentStrategy, long deploymentProjectId, long environmentId, int currentPosition, Optional<Long> relatedEnvId) Move Environment in given deploymentProject with given strategy.@NotNull ErrorCollectionmoveEnvironmentDown(long deploymentProjectId, long environmentId, int currentPosition) Deprecated.@NotNull ErrorCollectionmoveEnvironmentUp(long deploymentProjectId, long environmentId, int currentPosition) Deprecated.voidremoveRepositoryFromEnvironment(@NotNull EnvironmentRepositoryLink environmentRepositoryLink) RemoveEnvironmentRepositoryLinkfrom environmentvoidreplaceNotification(long environmentId, long oldNotificationId, @NotNull NotificationRule newRule) Replaces notification in the environment's notification set.voidresetTriggersForDeployment(long deploymentProjectId) Delete and recreate triggers for all environments for this deploymentvoidrestartAllTriggeringForDeploymentProject(long deploymentProjectId) Restart all automatic triggering on everyEnvironmentrelated to aDeploymentProject.voidstartAllTriggers(@NotNull Environment environment) Start all automatic triggering onInternalEnvironmentvoidstartAllTriggersForDeploymentProject(long deploymentProjectId) Start all automatic triggering on everyEnvironmentrelated to aDeploymentProjectvoidstopAllTriggers(@NotNull Environment environment) Stop all automatic triggering onInternalEnvironmentvoidstopAllTriggersForDeploymentProject(long deploymentProjectId) Stop all automatic triggering on everyEnvironmentrelated to aDeploymentProjectvoidupdateEnvironmentConfigurationState(long environmentId, @NotNull ConfigurationState configurationState) Update the configurationState of this environmentvoidupdateEnvironmentPrerequisites(long environmentId, @NotNull ReleaseApprovalPrerequisite releaseApprovalPrerequisite) Updates the prerequisites of the environment with requested ID needed to launch the release.voidupdatePlanKey(long deploymentProjectId, @NotNull PlanKey originalPlanKey, @NotNull PlanKey newPlanKey) Update planKey in Environment related configuration when plan key has changed (ie after moving plan).updateRepositoryLinkInEnvironment(EnvironmentRepositoryLink environmentRepositoryLink, RepositoryDataEntity newRepositoryEntity) UpdateEnvironmentRepositoryLinkdata@NotNull ErrorCollectionvalidateAddEnvironment(long deploymentProjectId, @Nullable String name, @Nullable String description) Validates values to be used for creating a new environment.@NotNull ErrorCollectionvalidateEditEnvironment(long environmentId, @Nullable String name, @Nullable String description) Validates values to be used when editing existing environment.
-
Field Details
-
DEFAULT_ARTIFACT_TASK_NAME
- See Also:
-
-
Method Details
-
getEnvironmentsForDeploymentProject
Get all environments for a particular deployment project. Does not validate deployment project actually exists.- Parameters:
deploymentProjectId- of the deployment project to get environments for- Returns:
- List of environments for a single deployment project. Sorted by position, name.
-
getEnvironmentStubsForDeploymentProject
@NotNull @NotNull List<EnvironmentStub> getEnvironmentStubsForDeploymentProject(long deploymentProjectId) Get all environment stubs for a particular deployment project. Does not validate deployment project actually exists. Returns minimum data set required for rendering on deployment project pages.- Parameters:
deploymentProjectId- of the deployment project to get environments for- Returns:
- List of environments for a single deployment project. Sorted by position, name.
-
getPaginatedEnvironmentsForDeploymentProject
@NotNull @NotNull PaginatedEnvironmentsForDashboard getPaginatedEnvironmentsForDeploymentProject(long deploymentProjectId, int start, int limit, @Nullable @Nullable String filter) Get paginated environments for a particular deployment project ordered by position. Does not validate deployment project actually exists. Filtering requires at least one character. If filter is null or empty then no filtering.- Parameters:
deploymentProjectId- of the deployment project to get environments forstart- start by indexlimit- return no more entries than limitfilter- filter- Returns:
- List of environments for a single deployment project. Sorted by position.
- See Also:
-
getEnvironmentsMatchingCapabilities
@Deprecated @NotNull @NotNull PaginatedEnvironmentsForExecutablesView getEnvironmentsMatchingCapabilities(int start, int limit, @Nullable @Nullable String filter, @NotNull @NotNull ReadOnlyCapabilitySet agentCapabilities) Deprecated.9.2, the method does not take into account the agent's assignments, usegetEnvironmentsMatchingCapabilities(int, int, String, ReadOnlyCapabilitySet, Iterable)insteadProvide a paginated list of minimal information about deployment environments matching agent capabilities.- Parameters:
start- start by indexlimit- return no more entries than limitfilter- filteragentCapabilities- capabilities of an agent- Returns:
- List of ids and name of deployment projects and environments, sorted alphabetically by deployment name and environment position;
-
getEnvironmentsMatchingCapabilities
@NotNull @NotNull PaginatedEnvironmentsForExecutablesView getEnvironmentsMatchingCapabilities(int start, int limit, @Nullable @Nullable String filter, @NotNull @NotNull ReadOnlyCapabilitySet agentCapabilities, @NotNull @NotNull Iterable<AgentAssignmentService.AgentAssignmentExecutor> agentAssignmentExecutors) Provide a paginated list of minimal information about deployment environments matching agent capabilities.- Parameters:
start- start by indexlimit- return no more entries than limitfilter- filteragentCapabilities- capabilities of an agentagentAssignmentExecutors- executors of agent assignment- Returns:
- List of ids and name of deployment projects and environments, sorted alphabetically by deployment name and environment position;
- Since:
- 9.2
-
getEnvironment
@Nullable @Nullable Environment getEnvironment(long environmentId) throws org.acegisecurity.AccessDeniedException Get specific environment by ID.- Parameters:
environmentId- ID to search for- Returns:
- environment with given ID or null if one could not be found.
- Throws:
org.acegisecurity.AccessDeniedException- when user doesn't have permissions to view environment
-
getEnvironmentUnrestricted
Get specific environment by ID. Does not check permissions.- Parameters:
environmentId- ID to search for- Returns:
- environment with given ID or null if one could not be found.
- Since:
- 7.1
-
validateAddEnvironment
@NotNull @NotNull ErrorCollection validateAddEnvironment(long deploymentProjectId, @Nullable @Nullable String name, @Nullable @Nullable String description) Validates values to be used for creating a new environment.- Parameters:
deploymentProjectId-name-description-- Returns:
- errorCollection containing any errors found. If no errors, an empty errorCollection will be returned.
-
addEnvironment
@NotNull default @NotNull Environment addEnvironment(long deploymentProjectId, @Nullable @Nullable String name, @Nullable @Nullable String description) throws WebValidationException Creates a new environment in the specified deployment project.- Parameters:
deploymentProjectId- to create environment inname- of the environment.description- of the environment.- Throws:
WebValidationException
-
addEnvironment
@NotNull @NotNull Environment addEnvironment(long deploymentProjectId, @Nullable @Nullable String name, @Nullable @Nullable String description, @Nullable @Nullable ReleaseApprovalPrerequisite environmentPrerequisites) throws WebValidationException Creates a new environment in the specified deployment project.- Parameters:
deploymentProjectId- to create environment inname- of the environment.description- of the environment.environmentPrerequisites- prerequisites needed to be met before launching release is possible- Throws:
WebValidationException- Since:
- 9.4
-
cloneEnvironment
Environment cloneEnvironment(long deploymentProjectId, long environmentId, @Nullable @Nullable String name, @Nullable @Nullable String description) throws WebValidationException Create new environment as a clone of existing one- Parameters:
environmentId-name-description-- Returns:
- Throws:
WebValidationException- when user has no permission to clone environment with dedicated agents or deployment/environment not found
-
cloneEnvironment
Environment cloneEnvironment(long deploymentProjectId, long environmentId, @Nullable @Nullable String name, @Nullable @Nullable String description, @NotNull @NotNull Map<String, String> oldAndClonedEnvironmentIds) throws WebValidationExceptionCreate new environment as a clone of existing one and if necessary update triggers' configuration- Parameters:
environmentId-name-description-oldAndClonedEnvironmentIds-- Returns:
- Throws:
WebValidationException- when user has no permission to clone environment with dedicated agents or deployment/environment not found
-
validateEditEnvironment
@NotNull @NotNull ErrorCollection validateEditEnvironment(long environmentId, @Nullable @Nullable String name, @Nullable @Nullable String description) Validates values to be used when editing existing environment.- Parameters:
environmentId- environment to editname- of the environmentdescription- of the environment- Returns:
- errorCollection containing any errors found. If no errors, an empty errorCollection will be returned.
-
editEnvironment
@NotNull @NotNull Environment editEnvironment(long environmentId, String name, String description) throws WebValidationException Edit the details of an existing environment- Parameters:
environmentId- environment to editname- of the environmentdescription- of the environment- Returns:
- the updated environment
- Throws:
WebValidationException
-
editEnvironment
@NotNull @NotNull Environment editEnvironment(long environmentId, String name, String description, @Nullable @Nullable ReleaseApprovalPrerequisite environmentPrerequisites) throws WebValidationException Edit the details of an existing environment- Parameters:
environmentId- environment to editname- of the environmentdescription- of the environmentenvironmentPrerequisites- prerequisites needed to be met before launching release is possible- Returns:
- the updated environment
- Throws:
WebValidationException- Since:
- 9.3
-
updateEnvironmentConfigurationState
void updateEnvironmentConfigurationState(long environmentId, @NotNull @NotNull ConfigurationState configurationState) Update the configurationState of this environment- Parameters:
environmentId- of environment to updateconfigurationState- new configuration state
-
getEnvironmentRequirementSet
Retrieve Agent Requirement set for environment, if environment with id exists.- Parameters:
environmentId- of environment- Returns:
- all requirements this environment has.
-
getAllEnvironments
Retrieve allEnvironmentdefined in the system. The result is filtered by environment permissions and sorted by deployment project id and environment position. Environments belonging to inaccessible projects are not currently filtered out, but their operations show them to be inaccessible. -
getAllEnvironmentsForDashboard
Retrieve allEnvironmentdefined in the system. The result is filtered by environment permissions and sorted by deployment project id and environment position. Environments belonging to inaccessible projects are not currently filtered out, but their operations show them to be inaccessible. Some data inside the object may be unavailable. -
getAllEnvironmentsNoUserContext
Deprecated.since 9.1 use paginated versiongetAllInternalEnvironmentsNoUserContext(int, int)Retrieve allEnvironmentdefined in the system without filling in operations permitted for the user. -
getAllEnvironmentsNoUserContext
Deprecated.since 9.3, avoid due to poor performance, usegetAllInternalEnvironmentsNoUserContext(int, int)Retrieve allEnvironmentdefined in the system without filling in operations permitted for the user.- Since:
- 9.1
-
getAllInternalEnvironmentsNoUserContext
@NotNull @NotNull Iterable<InternalEnvironment> getAllInternalEnvironmentsNoUserContext(int firstResult, int maxResults) Retrieve allEnvironmentdefined in the system without filling in operations permitted for the user.- Since:
- 9.1
-
countAll
long countAll() -
getRepositoryDefinitionsForEnvironment
@Deprecated @NotNull @NotNull List<RepositoryDefinition> getRepositoryDefinitionsForEnvironment(@NotNull @NotNull Environment environment) Deprecated.Retrieves all repositories used in environment source checkout tasks- Parameters:
environment-- Returns:
-
getPlanRepositoryDefinitionsForEnvironment
@NotNull @Deprecated @NotNull List<PlanRepositoryDefinition> getPlanRepositoryDefinitionsForEnvironment(@NotNull @NotNull Environment environment) Deprecated.Retrieves all repositories used in environment source checkout tasks- Parameters:
environment-- Returns:
-
getPlanRepositoryDefinitionsForEnvironment
@NotNull @NotNull List<PlanRepositoryDefinition> getPlanRepositoryDefinitionsForEnvironment(@NotNull @NotNull InternalEnvironment environment) Retrieves all repositories used in environment source checkout tasks- Parameters:
environment-- Returns:
-
getEnvironmentsUsingRepository
Deprecated.since 5.13, usegetEnvironmentRepositoryLinksForRepository(long) -
getEnvironmentRepositoryLinksForRepository
- Parameters:
repositoryId- repository id- Returns:
- list of Source Repository relationships defined for the given repository
-
getEnvironmentsUsingRepositoryDataEntity
TODO 6.0 rename to getEnvironmentsUsingRepository- Parameters:
repositoryId- repository id- Returns:
- list of immutable
Environments that use given repository
-
updateRepositoryLinkInEnvironment
RepositoryDefinition updateRepositoryLinkInEnvironment(EnvironmentRepositoryLink environmentRepositoryLink, RepositoryDataEntity newRepositoryEntity) UpdateEnvironmentRepositoryLinkdata- Parameters:
environmentRepositoryLink-newRepositoryEntity-- Returns:
-
removeRepositoryFromEnvironment
void removeRepositoryFromEnvironment(@NotNull @NotNull EnvironmentRepositoryLink environmentRepositoryLink) RemoveEnvironmentRepositoryLinkfrom environment- Parameters:
environmentRepositoryLink-
-
addNotification
void addNotification(long environmentId, @NotNull @NotNull NotificationRule newRule) throws WebValidationException Adds a new notification to the environment notifications- Throws:
WebValidationException
-
getNotificationSet
Retrieve notification set for environment, if environment with id exists.- Parameters:
environmentId- of environment
-
deleteNotification
Removes notification from the environment's notification set.- Throws:
WebValidationException
-
replaceNotification
void replaceNotification(long environmentId, long oldNotificationId, @NotNull @NotNull NotificationRule newRule) throws WebValidationException Replaces notification in the environment's notification set.- Throws:
WebValidationException- Since:
- 7.1
-
stopAllTriggers
Stop all automatic triggering onInternalEnvironment- Parameters:
environment-
-
startAllTriggers
Start all automatic triggering onInternalEnvironment- Parameters:
environment-
-
stopAllTriggersForDeploymentProject
void stopAllTriggersForDeploymentProject(long deploymentProjectId) Stop all automatic triggering on everyEnvironmentrelated to aDeploymentProject- Parameters:
deploymentProjectId-
-
startAllTriggersForDeploymentProject
void startAllTriggersForDeploymentProject(long deploymentProjectId) Start all automatic triggering on everyEnvironmentrelated to aDeploymentProject- Parameters:
deploymentProjectId-
-
restartAllTriggeringForDeploymentProject
void restartAllTriggeringForDeploymentProject(long deploymentProjectId) Restart all automatic triggering on everyEnvironmentrelated to aDeploymentProject. When using this method please keep in mind that triggers should be stopped before modifying their configuration and restarted afterwards. ThusstopAllTriggersForDeploymentProject(long)andstartAllTriggersForDeploymentProject(long)might be more useful. -
moveEnvironmentUp
@NotNull @Deprecated @NotNull ErrorCollection moveEnvironmentUp(long deploymentProjectId, long environmentId, int currentPosition) Deprecated.Moves an environment up the list -
moveEnvironmentDown
@NotNull @Deprecated @NotNull ErrorCollection moveEnvironmentDown(long deploymentProjectId, long environmentId, int currentPosition) Deprecated.Moves an environment down the list -
getEnvironmentCount
int getEnvironmentCount()- Returns:
- number of all environments
- Since:
- 5.3
-
getEnvironmentCountForProject
- Parameters:
deploymentProject-- Returns:
- number of environments defined for project
- Since:
- 5.1
-
updatePlanKey
void updatePlanKey(long deploymentProjectId, @NotNull @NotNull PlanKey originalPlanKey, @NotNull @NotNull PlanKey newPlanKey) Update planKey in Environment related configuration when plan key has changed (ie after moving plan). This method is called byDeploymentProjectService.updatePlanKey(PlanKey, PlanKey)after DeploymentProject has been updated.- Parameters:
deploymentProjectId- id of deployment project which environments have to be checkedoriginalPlanKey- original PlanKeynewPlanKey- new PlanKey- Since:
- 5.2
-
resetTriggersForDeployment
void resetTriggersForDeployment(long deploymentProjectId) Delete and recreate triggers for all environments for this deployment- Parameters:
deploymentProjectId-- Since:
- 5.11
-
getEnvironmentDecorator
Function<Environment,DecoratedEnvironment> getEnvironmentDecorator()Create environment decorator function object. Instances should be used for a single stream operation and should not live long. The function will return null if the user is not allowed to see the corresponding deployment project. -
findEnvironmentsByRequirementKey
@NotNull @NotNull Set<RequirementDeploymentMapping> findEnvironmentsByRequirementKey(@NotNull @NotNull String requirementKey) Find environments which rely on requirementKey- Parameters:
requirementKey- on which environments rely- Returns:
- environments or empty set
- Since:
- 5.13
-
createImmutableEnvironment
@NotNull @NotNull Environment createImmutableEnvironment(@NotNull @NotNull MutableEnvironment environment) Converts mutable environment to immutable.- Since:
- 6.1
-
findEnvironmentByName
Find environment with specified name in a deployment project- Parameters:
deploymentProjectId-name-- Since:
- 6.8
-
createOperationsAwareImmutableEnvironment
@NotNull @NotNull Environment createOperationsAwareImmutableEnvironment(@NotNull @NotNull MutableEnvironment environment) Create operation aware immutable environment- Since:
- 6.8
- See Also:
-
updateEnvironmentPrerequisites
void updateEnvironmentPrerequisites(long environmentId, @NotNull @NotNull ReleaseApprovalPrerequisite releaseApprovalPrerequisite) Updates the prerequisites of the environment with requested ID needed to launch the release.- Parameters:
environmentId- id of the environmentreleaseApprovalPrerequisite- new prerequisites- Since:
- 9.4
-
moveEnvironment
ErrorCollection moveEnvironment(MoveEnvironmentStrategy moveEnvironmentStrategy, long deploymentProjectId, long environmentId, int currentPosition, Optional<Long> relatedEnvId) Move Environment in given deploymentProject with given strategy. relatedEnvId is optional for most cases. It is only required for strategyMoveEnvironmentStrategy.AFTERorMoveEnvironmentStrategy.BEFORE- Parameters:
moveEnvironmentStrategy-deploymentProjectId-environmentId-currentPosition-relatedEnvId-- Returns:
- error collection
- Since:
- 6.8
-
getAllInternalEnvironmentsNoUserContext(int, int)