Class BuildPromotionImpl

    • Constructor Detail

      • BuildPromotionImpl

        public BuildPromotionImpl​(@NotNull
                                  SBuildType buildType,
                                  @NotNull
                                  BuildPromotionContext context)
        Constructor for new build promotion, will generate new id and persist it in database
      • BuildPromotionImpl

        public BuildPromotionImpl​(long id,
                                  @NotNull
                                  String buildTypeId,
                                  @Nullable
                                  Long lastModificationId,
                                  @Nullable
                                  Long chainModificationId,
                                  boolean personal,
                                  @Nullable
                                  Long personalChangeId,
                                  @Nullable
                                  Long ownerId,
                                  boolean changesDetached,
                                  boolean deleted,
                                  boolean incomplete,
                                  @Nullable
                                  String branchName,
                                  @Nullable
                                  Long buildId,
                                  @Nullable
                                  Date queuedTimestamp,
                                  @Nullable
                                  Date removedFromQueueTimestamp,
                                  @NotNull
                                  BuildPromotionContext context,
                                  @NotNull
                                  Map<String,​Object> attributes,
                                  @Nullable
                                  Map<Long,​Integer> dependenciesOptions,
                                  @Nullable
                                  List<BuildRevisionData> revisions,
                                  boolean associatedBuildFinished)
        Constructor for existing build promotion, i.e. when promotion is restored from database Constructor is also called to create DummyBuildPromotion
    • Method Detail

      • getId

        public long getId()
        Description copied from interface: BuildPromotion
        Returns id of this promotion, promotion id is unique among all other build promotions and is not changed during promotion life cycle.
        Returns:
        id of this build promotion
      • isPersonal

        public boolean isPersonal()
        Description copied from interface: BuildPromotion
        Return true if this build promotion relates to personal build
        Returns:
        see above
      • getPersonalChangeId

        public Long getPersonalChangeId()
        Description copied from interface: BuildPromotionEx
        Returns personal change id associated with this build promotion. If promotion is not personal (isPersonal == false), returns null.
        Returns:
        see above
      • hasCustomPatch

        public boolean hasCustomPatch()
        Returns:
        true if this build promotion has a custom patch associated with it which should be applied when build starts on an agent
      • getCustomParametersCollection

        @NotNull
        public Collection<Parameter> getCustomParametersCollection()
        Description copied from interface: BuildPromotionEx
        Returns a collection of user-defined build and configuration parameters associated with this build promotion.
        Returns:
        see above
      • setBuildRevisions

        public void setBuildRevisions​(@NotNull
                                      Collection<BuildRevisionEx> revisions,
                                      long maxModificationId,
                                      long chainModificationId,
                                      boolean validateBranch)
        Description copied from interface: BuildPromotionEx
        Sets revisions and modificationId into this build promotion. If revisions list is empty, that means that changes were not collected for this build
        Parameters:
        revisions - list of revisions for this build. If empty, changes were not collected for the build (possibly, because of some failure)
        maxModificationId - modification id associated with this build, used to determine changes in this build
        chainModificationId - max mod id associated with this build configuration or its dependencies transitively, cannot be smaller than maxModificationId
        validateBranch - if set to true then branch validation logic is enabled; the validation will check whether the current build branch exists in any of the VCS roots in the provided revisions, and if it does not then a build problem will be added to the build
        See Also:
        BuildPromotion.getRevisions(), BuildPromotion.getLastModificationId()
      • resetBuildRevisions

        public void resetBuildRevisions()
      • getAutogeneratedBranchName

        @Nullable
        public String getAutogeneratedBranchName()
        Description copied from interface: BuildPromotionEx
        Returns auto-generated branch name for the case if build promotion VCS roots differ from VCS roots in build configuration. The auto-generated name will have diff of changed settings.
        Returns:
        auto-generated name or null if settings do not differ
      • getRevisions

        @NotNull
        public List<BuildRevision> getRevisions()
        Description copied from interface: BuildPromotion
        Returns VCS root revisions associated with this promotion.
        Returns:
        VCS root revisions
      • getAllRevisionsMap

        @NotNull
        public Map<VcsRootInstance,​BuildRevisionEx> getAllRevisionsMap()
        Description copied from interface: BuildPromotionEx
        Returns all vcs root revisions assciated with build, not only regular vcs roots attached to the build configurations.
        Returns:
        see above
      • getVcsRootEntries

        @NotNull
        public List<VcsRootInstanceEntry> getVcsRootEntries()
        Description copied from interface: BuildPromotion
        Returns VCS root entries associated with this promotion.
        Returns:
        VCS root entries
      • getVcsRootEntries

        @NotNull
        public List<VcsRootInstanceEntry> getVcsRootEntries​(boolean includeSettingsRoot)
        Description copied from interface: BuildPromotionEx
        Returns entries for VCS roots associated with this promotion. If promotion has an implicit settings root (not attached to buildType) and includeSettingsRoot is true, then an entry for this settings root is included in the result.
        Parameters:
        includeSettingsRoot - whether settings root should be included in result
        Returns:
        see above
        See Also:
        BuildTypeEx.getVcsRootInstanceEntries(boolean)
      • modId

        @Nullable
        public static Long modId​(Long id)
      • getLastModificationId

        public Long getLastModificationId()
        Description copied from interface: BuildPromotion
        Returns id of the last change associated with this promotion or null if changes collecting is not performed yet. Returns -1 if changes collecting is performed but there were no changes detected and there were no changes in the build configuration since its creation.
        Returns:
        see above
      • getChainModificationId

        @Nullable
        public Long getChainModificationId()
        Description copied from interface: BuildPromotionEx
        Returns max modification id (max result of #getLastModificationId()) among this promotion all all its dependencies transitively. Returns null if changes are not collected for this promotion yet or if this is an old promotion created before the chain modification id was introduced. Returns -1 if changes collecting was performed but there were no changes detected and there were no changes in this build configuration and its dependencies since their creation.
        Returns:
        see above
      • getAssociatedBuild

        @Nullable
        public SBuild getAssociatedBuild()
        Description copied from interface: BuildPromotion
        Returns running or finished build associated with this promotion or null if there is no such build.
        Returns:
        see above
      • getQueuedBuild

        public QueuedBuildEx getQueuedBuild()
        Description copied from interface: BuildPromotion
        Returns queued build associated with this promotion or null if there is no such build in the queue
        Returns:
        see above
      • getBuildComment

        public Comment getBuildComment()
        Description copied from interface: BuildPromotion
        Returns build comment assigned for this promotion
        Returns:
        build comment
      • setBuildComment

        public void setBuildComment​(@NotNull
                                    User user,
                                    @Nullable
                                    String comment)
        Description copied from interface: BuildPromotion
        Assigns the build comment for this promotion
        Parameters:
        user - user who sets the comment
        comment - text of the comment
      • getAuditLogActions

        @NotNull
        public List<AuditLogAction> getAuditLogActions​(@Nullable
                                                       AuditLogFilter filter)
        Parameters:
        filter - if not null the filter is applied to the returned set of objects
        Returns:
        audit log actions associated with this promotion
      • getAuditLog

        @NotNull
        public AuditLog getAuditLog()
        Returns:
        audit log which can be used to log user actions for this build promotion
      • resetLogActionsCache

        public void resetLogActionsCache()
        Description copied from interface: BuildPromotionEx
        Reset cached audit log
      • resetTagsCache

        public void resetTagsCache()
        Description copied from interface: BuildPromotionEx
        Reset cached tags
      • getCollectChangesError

        @Nullable
        public String getCollectChangesError()
      • isFailedToCollectChanges

        public boolean isFailedToCollectChanges()
        Returns:
        true if process of changes collecting failed for this build
      • setFailedToCollectChanges

        public void setFailedToCollectChanges​(@Nullable
                                              Throwable collectChangesException)
      • getAssociatedBuildId

        public Long getAssociatedBuildId()
        Description copied from interface: BuildPromotion
        Returns id of the build associated with this promotion, or null if there is no such build.
        Returns:
        see above
      • isLaterThan

        public boolean isLaterThan​(@NotNull
                                   BuildPromotion promotion)
        Description copied from interface: BuildPromotion
        Returns true if this promotion contains more recent changes comparing to the specified promotion.
        Parameters:
        promotion - promotion
        Returns:
        see above
      • getCustomParameters

        @NotNull
        public Map<String,​String> getCustomParameters()
        Description copied from interface: BuildPromotion
        Returns map of user-defined build and configuration parameters associated with this build promotion.
        Returns:
        see above
      • getDefaultParameters

        @NotNull
        public Map<String,​String> getDefaultParameters()
        Description copied from interface: BuildPromotion
        Returns map of default build and configuration parameters associated with this build promotion. Default parameters are taken from the build configuration when build promotion is created.
        Returns:
        see above
      • getParameters

        @NotNull
        public Map<String,​String> getParameters()
        Description copied from interface: BuildPromotion
        Returns combined map of default and custom parameters. Combined map contains both build and configuration parameters. Custom parameters take precedence over default parameters.

        Note that parameters returned by this method can be modified before they are passed to agent, see ParametersPreprocessor for more details.

        Returns:
        see above
      • getParameterValue

        @Nullable
        public String getParameterValue​(@NotNull
                                        String paramName)
        Parameters:
        paramName - parameter name
        Returns:
        value of the parameter with given name or null if there is no such parameter
      • getParametersCollection

        @NotNull
        public Collection<Parameter> getParametersCollection()
        Description copied from interface: ReadOnlyUserParameters
        Returns build and configuration parameters in single collection.
        Returns:
        see above
      • getParameter

        @Nullable
        public Parameter getParameter​(@NotNull
                                      String paramName)
      • getBranch

        @Nullable
        public Branch getBranch()
        Returns:
        branch associated with this build promotion if it exists and null otherwise.
      • getCheckoutDirectory

        @Nullable
        public String getCheckoutDirectory()
      • getFrozenSettingsFile

        @NotNull
        public File getFrozenSettingsFile()
        Returns:
        path to file with frozen settings.
      • hasFrozenSettings

        public boolean hasFrozenSettings()
        Returns:
        true if settings of this promotion were frozen.
      • hasFrozenSettingsFromVcs

        public boolean hasFrozenSettingsFromVcs()
        Returns:
        true if this promotion has frozen settins from VCS
      • needToFreezeSettings

        public boolean needToFreezeSettings()
        Returns:
        true if there was no attempt to freeze settings (successful or failed)
      • getBuildParameters

        @NotNull
        public Map<String,​String> getBuildParameters()
        Description copied from interface: BuildPromotion
        Returns combined map of default and custom defined build parameters. Custom build parameters takes precedence over default parameters.

        Note that parameters returned by this method can be modified before they are passed to agent, see ParametersPreprocessor for more details.

        Returns:
        see above
      • setCustomParameters

        public void setCustomParameters​(@NotNull
                                        Map<String,​String> customParameters)
        Description copied from interface: BuildPromotionEx
        Sets custom parameters in build promotion. Custom parameters contain both configuration and build parameters. Custom parameters override default parameters. BuildPromotion.persist() method should be called to persist them.
        Parameters:
        customParameters - custom parameters
      • setCustomParameters

        public void setCustomParameters​(@NotNull
                                        Collection<Parameter> parameters)
        Description copied from interface: BuildPromotionEx
        Same as #setCustomParameters(List) but accepting Parameter instances
      • getOverridenVcsRoots

        @NotNull
        public Map<VcsRootInstance,​VcsRootInstance> getOverridenVcsRoots()
        Description copied from interface: BuildPromotionEx
        Get overriden vcs root map in this promotion.
        Returns:
        map from original vcs root id to substitution root id
      • setAttribute

        public final void setAttribute​(@NotNull
                                       String name,
                                       @Nullable
                                       Object value)
        Description copied from interface: BuildPromotionEx
        Sets some attribute to the build promotion
        Parameters:
        name - attribute name
        value - attribute value
      • getAttributes

        @NotNull
        public Map<String,​Object> getAttributes()
        Returns:
        map of arbitrary options associated with this promotion.
      • getAttribute

        @Nullable
        public Object getAttribute​(@NotNull
                                   String attributeName)
      • getProjectId

        public String getProjectId()
        Description copied from interface: BuildPromotion
        Returns the project internal id.
        Returns:
        project internal id
      • getProjectExternalId

        public String getProjectExternalId()
        Description copied from interface: BuildPromotion
        Returns the project external id
        Returns:
        project external id
      • setAssociatedBuild

        public void setAssociatedBuild​(SBuild build)
        Description copied from interface: BuildPromotionEx
        Associates new build to this build promotion
      • isUsed

        public boolean isUsed()
        Description copied from interface: BuildPromotion
        Returns true if there is a reference to this build promotion from queued, running or history build.
        Returns:
        see above
      • copy

        @NotNull
        public BuildPromotionEx copy​(boolean copyRevisions)
        Description copied from interface: BuildPromotion
        Creates copy of this build promotion (a copy will have different id). Note that this method does not make a deep copy if dependencies exist.
        Parameters:
        copyRevisions - indicates whether to copy revisions associated with this promotion or not
        Returns:
        copy of this build promotion
      • isOutOfChangesSequence

        public boolean isOutOfChangesSequence()
        Description copied from interface: BuildPromotion
        Returns true if there is a build started before this build promotion associated build which contains more recent changes.
        Returns:
        see above
      • isPartOfBuildChain

        public boolean isPartOfBuildChain()
        Returns:
        true if this build promotion is a part of build dependencies graph, i.e. there are promotions having dependencies on this promotion or this promotion has dependencies on other promotions.
      • getDependencies

        @NotNull
        public Collection<BuildDependencyEx> getDependencies()
        Description copied from interface: BuildPromotion
        Returns the direct snapshot dependencies of this build promotion filtered according to current user permissions.
        Returns:
        see above
      • getDependedOnMeIds

        @NotNull
        public Collection<Long> getDependedOnMeIds()
      • getDependenciesIds

        @NotNull
        public Collection<Long> getDependenciesIds()
      • hasDependencyOn

        public boolean hasDependencyOn​(long id)
      • getNumberOfDependencies

        public int getNumberOfDependencies()
        Description copied from interface: BuildPromotion
        Returns total number of snapshot dependencies (without permissions filtering).
        Returns:
        see above
      • findTops

        public BuildPromotionEx[] findTops()
        Description copied from interface: BuildPromotion
        Return a collection of top-level build promotions for sequence builds this build promotion participates in. This build promotion may have several tops only if it has an associated running or finished build. If this build promotion is a top of the graph, returns an array with itself as the only element. This method always returns at least one element. The array of build promotions is sorted in a way that the most recent top of the graph is returned first.
        Returns:
        see above
      • getDependedOnMe

        @NotNull
        public Collection<BuildDependencyEx> getDependedOnMe()
        Description copied from interface: BuildPromotion
        Returns snapshot dependencies of parent build promotions depending on this promotion. Parent build promotions are filtered according to current user permissions.
        Returns:
        see above
      • traverseDependedOnMe

        public void traverseDependedOnMe​(@NotNull
                                         DependencyConsumer<BuildPromotionEx> consumer)
        Description copied from interface: BuildPromotionEx
        Traverses all build promotions depending on this one transitively. If processor returns false, traversing stops.
      • createBuildPromotionAccessChecker

        @NotNull
        public Predicate<BuildPromotion> createBuildPromotionAccessChecker()
      • traverseDependencies

        public void traverseDependencies​(@NotNull
                                         DependencyConsumer<BuildPromotionEx> consumer)
        Description copied from interface: BuildPromotionEx
        Traverses all build promotion dependencies (breadth first). If processor returns false, traversing stops.
      • getNumberOfDependedOnMe

        public int getNumberOfDependedOnMe()
        Description copied from interface: BuildPromotion
        Returns total number of parent snapshot dependencies (without permissions filtering).
        Returns:
        see above
      • removeDependency

        public void removeDependency​(@NotNull
                                     BuildPromotionEx promo)
        Description copied from interface: BuildPromotionEx
        Removes dependency on specified promotion
      • replaceDependency

        public void replaceDependency​(@NotNull
                                      BuildPromotionEx origPromo,
                                      @NotNull
                                      BuildPromotionEx newPromo,
                                      @NotNull
                                      DependencyOptions newOptions)
        Description copied from interface: BuildPromotionEx
        Replaces dependency on one promotion with dependency to another promotion
        Parameters:
        origPromo - original promotion
        newPromo - replacement
      • addToQueue

        @Nullable
        public SQueuedBuild addToQueue​(@NotNull
                                       String requestor)
        Description copied from interface: BuildPromotion
        Creates a new build on the base of this promotion (and all necessary builds for the promotions this one depends on) and adds it to the Queue.
        Parameters:
        requestor - contains details about who triggered build, see also TriggeredByBuilder
        Returns:
        the queued build or null if adding to queue is impossible for some reason
      • addToQueue

        @Nullable
        public SQueuedBuild addToQueue​(@NotNull
                                       SBuildAgent buildAgent,
                                       @NotNull
                                       String requestor)
        Description copied from interface: BuildPromotion
        Creates a new build on the base of this promotion (and all necessary builds for the promotions this one depends on) and adds it to the Queue.
        Parameters:
        buildAgent - build agent where the build is to run
        requestor - contains details about who triggered build, see also TriggeredByBuilder
        Returns:
        the queued build or null if adding to queue is impossible for some reason
      • getBuildType

        @Nullable
        public BuildTypeEx getBuildType()
        Description copied from interface: BuildPromotion
        Returns build configuration to which this promotion corresponds. If promotion is for personal build, returns RemoteBuildType.

        If the correspondent build configuration is deleted - returns null.

        Returns:
        the correspondent build configuration or null if that was deleted.
      • getOwner

        @Nullable
        public SUser getOwner()
        Description copied from interface: BuildPromotion
        For personal builds returns owner of the build. For non personal builds returns null.
        Returns:
        see above
      • getBuildTypeId

        @NotNull
        public String getBuildTypeId()
        Description copied from interface: BuildPromotion
        Returns internal id of build configuration to which this promotion corresponds, same as BuildPromotion.getBuildType().getBuildTypeId()
        Returns:
        id of build configuration
      • getParentBuildTypeId

        @NotNull
        public String getParentBuildTypeId()
        Description copied from interface: BuildPromotion
        For non personal builds returns same as BuildPromotion.getBuildTypeId(). For personal builds returns id of parent build configuration: getParentBuildType().getBuildTypeId()
        Returns:
        see above
      • getBuildTypeExternalId

        @NotNull
        public String getBuildTypeExternalId()
        Description copied from interface: BuildPromotion
        Returns the external id of the associated build type. In case of the personal build - it is the identifier of the real build configuration (as for a regular build), without suffixes.

        If the external identifier does not exist (this might happen for a running build if the build type was deleted, and a new build type with same external id was created), a BuildPromotion.NOT_EXISTING_BUILD_TYPE_ID value is returned.

        Returns:
        the external identifier of the associated build type.
      • getParentBuildType

        @Nullable
        public BuildTypeEx getParentBuildType()
        Description copied from interface: BuildPromotion
        Returns base build configuration to which this promotion corresponds, i.e. for personal builds returns parent build configuration, not the personal build type
        Returns:
        see above
      • isEquivalentTo

        public boolean isEquivalentTo​(@NotNull
                                      BuildPromotion promotion)
        Description copied from interface: BuildPromotion
        Returns true if this build promotion is equivalent to specified promotion, i.e. it corresponds to the same build configuration, contains same revisions and build parameters.
        Parameters:
        promotion - build promotion
        Returns:
        see above
      • isEquivalentTo

        @NotNull
        public EquivalenceCheckResult isEquivalentTo​(@NotNull
                                                     BuildPromotion promotion,
                                                     @Nullable
                                                     Boolean compareBranches)
        Parameters:
        promotion - build promotion to compare with
        compareBranches - whether to compare branches strictly or not
        Returns:
        object with reason why builds are not equivalent
      • getSettingsDigest

        @NotNull
        public byte[] getSettingsDigest​(boolean compute)
        Description copied from interface: BuildPromotionEx
        Returns digest of build promotion settings. If build promotion has build, then digest will be taken from the build artifacts. If there is no digest in artifacts, it will be computed by current settings if compute is set to true. Digest is always computed if build promotion does not have build associated. Returns empty array if digest cannot be computed or build does not have digest and compute is set to false
        Specified by:
        getSettingsDigest in interface BuildPromotionEx
        Overrides:
        getSettingsDigest in class AbstractBuildPromotion
        Parameters:
        compute - if true and build promotion has build without digest, then digest will be calculated
      • setQueuedAt

        public void setQueuedAt​(Date queuedAt)
      • setRemoveFromQueueDate

        public void setRemoveFromQueueDate​(@Nullable
                                           Date removeFromQueueDate)
      • setArtifactsDirectory

        public void setArtifactsDirectory​(@NotNull
                                          File artifactsDir)
        Description copied from interface: BuildPromotionEx
        Sets new artifacts directory to this build promotion. This method also persists new artifacts directory in database, not additional call to BuildPromotionEx.persist() is required.
        Parameters:
        artifactsDir - new artifacts directory
      • isFinished

        public boolean isFinished()
        Returns:
        true if build associated with this promotion is finished. Method is not optimized for performance, and can perform one SQL query to determine whether build is finished or not.
      • getProjectPathIds

        @NotNull
        public List<String> getProjectPathIds()
        Description copied from interface: BuildPromotionEx
        Returns project path of a project where this build promotion belongs. Project path is fixed on the moment when some build is associated with this promotion. List contains internal ids of the projects. The first element in the list is root project id, while the last element contains id of the build promotion project.
        The list can be empty.
      • getOwnerNodeUrl

        @Nullable
        public String getOwnerNodeUrl()
        Description copied from interface: BuildPromotionEx
        Returns url of the node which processes this build messages. Returns null if this build promotion is not assigned to any node. Returns BuildPromotionEx.MAIN_NODE_MARKER if build promotion was specifically assigned to main node.
      • getOwnerNode

        @Nullable
        public TeamCityNode getOwnerNode()
        Returns:
        TeamCityNode of build messages processor type if this promotion was assigned to such a node using setOwnerNodeUrl call; returns null in all other cases.
      • setOwnerNodeUrl

        public void setOwnerNodeUrl​(@Nullable
                                    String newUrl)
        Description copied from interface: BuildPromotionEx
        Sets url of the node which processes this build messages.
      • getBuildLog

        @NotNull
        public BuildLogEx getBuildLog()
        Returns:
        Log for operations which could occur before build start, like changes collecting or logging detailed triggering information.
      • getBuildLogIfInitialized

        @Nullable
        public BuildLogEx getBuildLogIfInitialized()
      • resetBuildLog

        public void resetBuildLog()
      • buildFinished

        public void buildFinished()
        Description copied from interface: BuildPromotionEx
        Must be called when build history entry created for this promotion.
      • buildEvictedFromCache

        public void buildEvictedFromCache()
        Description copied from interface: BuildPromotionEx
        Called when finished build associated with this promotion is removed from the builds cache. In this case promotion can clear some of its internal objects and free some memory.
      • associatedBuildFinished

        public void associatedBuildFinished()
      • isAssociatedBuildFinished

        public boolean isAssociatedBuildFinished()
      • isChangeCollectingNeeded

        public boolean isChangeCollectingNeeded()
        Description copied from interface: BuildPromotionEx
        Return true if change collection is required for this build promotion (otherwise, changes are collected already).
        Returns:
        see above
      • isCanceled

        public boolean isCanceled()
        Description copied from interface: BuildPromotion
        Return true if associated build is canceled
        Returns:
        see above
      • getStartedEquivalentPromotions

        @NotNull
        public List<BuildPromotionEx> getStartedEquivalentPromotions​(int maxNumToProcess)
        Description copied from interface: BuildPromotionEx
        Returns build promotions with associated builds and equivalent to this build promotion (same settings, changes and revisions)
        Parameters:
        maxNumToProcess - maximum number of promotions to process while searching for equivalent promotions, -1 means unlimited
        Returns:
        see above
      • getEquivalentPromotions

        @NotNull
        public List<BuildPromotionEx> getEquivalentPromotions​(@NotNull
                                                              List<BuildPromotionEx> promotions)
        Description copied from interface: BuildPromotionEx
        Returns build promotions from the build queue equivalent to this build promotion (same settings, changes and revisions)
        Returns:
        see above
      • markIncomplete

        public void markIncomplete()
        Description copied from interface: BuildPromotionEx
        Mark build promotion as incomplete (canceled)
      • markAsIncompleteIfHasFailedToStartProblems

        public void markAsIncompleteIfHasFailedToStartProblems()
        Description copied from interface: BuildPromotionEx
        Marks build promotion as incomplete if it has failed to start build problems
      • isIncomplete

        public boolean isIncomplete()
        Description copied from interface: BuildPromotionEx
        Returns whether the build promotion is incomplete (canceled). Method is efficient enough, can be called often.
        Returns:
        true iff is incomplete
      • markDeleted

        public void markDeleted()
        Description copied from interface: BuildPromotionEx
        Mark this promotion as deleted in the database. This makes this promotion 'invisible' for most queries, and it becomes a subject for cleanup. If there is an associated finishedBuild with this promotion, this finished build is considered deleted as well, i.e. various 'buildDeleted' events are sent.
      • isDeleted

        public boolean isDeleted()
        Returns:
        true if promotion is marked as deleted
      • isPersisted

        public boolean isPersisted()
        Returns:
        true if this promotion was ever persisted into the database, so the method will return true even if markDeleted() was called for this promotion and promotion was previously stored in database
      • hasStartedParent

        public boolean hasStartedParent()
        Description copied from interface: BuildPromotionEx
        Returns true if there exists started build which has reference to this promotion
        Returns:
        see above
      • persist

        public void persist()
        Description copied from interface: BuildPromotionEx
        Persists state of the build promotion
      • hasDirtyState

        @TestOnly
        public boolean hasDirtyState()
      • updateStateFromBuildData

        public void updateStateFromBuildData​(@NotNull
                                             AbstractBuildData buildData)
        Description copied from interface: BuildPromotionEx
        Quickly updates some information in build promotion from DB information. Doesn't store anything back to DB
      • persistVcsRootEntries

        public void persistVcsRootEntries()
        Persists promotion VCS root entries to the database to make them visible by other nodes.
      • persistDependencies

        public void persistDependencies()
      • detachChanges

        public void detachChanges()
        Description copied from interface: BuildPromotionEx
        Marks build as build with detached changes, i.e. changes of this build will be shown in the next build too.
      • isChangesDetached

        public boolean isChangesDetached()
        Returns:
        true if changes are detached from this promotion, i.e. next build will have all of the changes included in this promotion.
      • setFinalArtifactDependencies

        public void setFinalArtifactDependencies​(@NotNull
                                                 List<SArtifactDependency> dependencies)
        Description copied from interface: BuildPromotionEx
        Sets the final artifact dependencies, i.e. those which must be sent to an agent.
        Parameters:
        dependencies - the artifact dependencies
      • setCustomArtifactDependencies

        public void setCustomArtifactDependencies​(@NotNull
                                                  List<SArtifactDependency> dependencies)
        Description copied from interface: BuildPromotionEx
        Sets custom artifact dependencies, those which override default (specified in build configuration). Custom artifact dependencies will override default completely. If list is empty, it will reset custom artifact dependencies.
        Parameters:
        dependencies - custom dependencies
      • getArtifactDependencies

        @NotNull
        public List<SArtifactDependency> getArtifactDependencies()
        Description copied from interface: BuildPromotion
        Returns collection of artifact dependencies to be sent to an agent. This collection may or may not be the same as default build configuration dependencies because before sending to an agent revision rules are fixed (dependencies begin pointing to concrete builds).
        Returns:
        see above
      • setDesiredBranchName

        public void setDesiredBranchName​(@NotNull
                                         String branchName)
      • getInternalBranchName

        @NotNull
        public String getInternalBranchName()
        Returns:
        internal branch name associated with build promotion. If build promotion belongs to default branch or is not branched, returns empty string.
      • isCompositeBuild

        public boolean isCompositeBuild()
        Returns:
        true if build promotion has dependencies and it was created in a build configuration marked as composite build
      • getCreatorNodeId

        @NotNull
        public String getCreatorNodeId()
        Returns:
        node id which created the build promotion.
      • allDependenciesFinished

        public boolean allDependenciesFinished()
        Returns:
        true if all direct dependencies of this build promotion are finished
      • getDependentCompositePromotions

        @NotNull
        public List<BuildPromotionEx> getDependentCompositePromotions()
        Returns:
        list of all composite promotions depending on this build promotion either directly or transitively
      • decreaseExpirationCounter

        public int decreaseExpirationCounter​(int decreaseAmount)
      • setExpirationCounter

        public void setExpirationCounter​(int counter)
      • hasComputedArtifactsState

        public boolean hasComputedArtifactsState()
      • artifactsChanged

        public void artifactsChanged​(boolean scheduleUpdate)
        Description copied from interface: BuildPromotionEx
        Should be called when artifacts are changed on disk.
        Parameters:
        scheduleUpdate - if true, a task should be scheduled to update artifacts state
      • hasUnpublishedPromotionPersistingEvent

        public boolean hasUnpublishedPromotionPersistingEvent()
        Returns:
        true if "promotion persisted" event for this build promotion is not yet stored in DB
      • resetArtifactsState

        public void resetArtifactsState​(boolean scheduleUpdate)
        Description copied from interface: BuildPromotionEx
        Resets current artifacts state in the build promotion
        Parameters:
        scheduleUpdate - if true, a task should be scheduled to update artifacts state, otherwise state will be calculated when BuildPromotionEx.getArtifactStateInfo() is called
      • getArtifacts

        @NotNull
        public BuildArtifacts getArtifacts​(@NotNull
                                           BuildArtifactsViewMode mode)
        Description copied from interface: BuildPromotionEx
        Returns artifacts of this build promotion.
        Parameters:
        mode - artifacts view mode
        Returns:
        object describing artifacts of this build promotion.
      • isChangesCollectingInProgress

        public boolean isChangesCollectingInProgress()
      • scheduleCheckingForChangesIfNeeded

        public boolean scheduleCheckingForChangesIfNeeded()
        Returns:
        true if checking for changes was scheduled and false if it was not, because build promotion has changes collected already
      • updateSelfAndDependenciesFromDB

        public void updateSelfAndDependenciesFromDB()
        Description copied from interface: BuildPromotionEx
        Updates the build promotion and all its dependencies from the database
      • cancelCheckingForChanges

        public void cancelCheckingForChanges()
      • lockDependenciesOptimizing

        public void lockDependenciesOptimizing()
      • unlockDependenciesOptimizing

        public void unlockDependenciesOptimizing()
      • addDependedOnMeIfCached

        public void addDependedOnMeIfCached​(@NotNull
                                            BuildPromotionEx promotion,
                                            @NotNull
                                            DependencyOptions options)
        Description copied from interface: BuildPromotionEx
        Adds link to parent promotion only if depended on me list is already loaded from DB for this promotion
      • removeDependedOnMe

        public void removeDependedOnMe​(@NotNull
                                       BuildPromotion parentPromo)
        Description copied from interface: BuildPromotionEx
        Removes link to parent promotion
      • addBuildProblem

        public void addBuildProblem​(@NotNull
                                    BuildProblemData buildProblem)
        Description copied from interface: BuildPromotionEx
        Adds build problem, currently it actually causes build failure
      • getFailureReasons

        @NotNull
        public List<BuildProblemData> getFailureReasons()
        Description copied from interface: BuildPromotionEx
        Returns non-muted build problems for this promotion Note that this mathod may cause DB call, if you only require the fact if there are any failure reasons use hasFailureReasons which is guaranteed fast
      • hasFailureReasons

        public boolean hasFailureReasons()
      • muteBuildProblems

        public void muteBuildProblems​(boolean muteIfTrue,
                                      @Nullable
                                      SUser user,
                                      @Nullable
                                      String comment)
        Description copied from interface: BuildPromotionEx
        Makes all existing build problems enabled or disabled
        Parameters:
        muteIfTrue - pass true to make build successful, false to make existing problems visible again
      • getBuildProblems

        @NotNull
        public List<BuildProblem> getBuildProblems()
        Description copied from interface: BuildPromotionEx
        Returns all build problems for this promotion with extended information about muting. The problems are sorted in order of their appearance.
        Returns:
        see above
      • getBuildChainProblems

        @NotNull
        public List<BuildProblem> getBuildChainProblems​(boolean omitInduced)
        Description copied from interface: BuildPromotionEx
        If omitInduced is false, simply traverses all of the dependencies of this promotion and returns collection of all build problems (including this promotion own problems). If omitInduced is true, returns only those build problems which caused failure of this build promotion (root causes). Returned list will not have build problems of snapshot dependency type (see ErrorData.isSnapshotDependencyError(String)) as such problems are induced and never represent the root cause.
        Parameters:
        omitInduced - see above
        Returns:
        list of own problems as well as problems from snapshot dependencies transitively
      • hasBuildProblemsOfType

        public boolean hasBuildProblemsOfType​(@NotNull
                                              String type)
        Returns:
        true if there are build problems with specified type
      • deleteBuildProblem

        public void deleteBuildProblem​(@NotNull
                                       String identity)
        Description copied from interface: BuildPromotionEx
        Deletes build problem Deleting build problem may change build status to SUCCESS
        Parameters:
        identity - identiry of build problem to be removed
      • initBuildProblems

        public void initBuildProblems()
        Description copied from interface: BuildPromotionEx
        Init build problems from database
      • resetDependentOnMeCache

        public void resetDependentOnMeCache()
        Description copied from interface: BuildPromotionEx
        reset only dependent on this cache of the promotion.
      • ensureBuildLogFlushed

        public void ensureBuildLogFlushed()
        Description copied from interface: BuildPromotionEx
        Makes sure that messages in the build log buffer are flushed on disk.
      • resetDirectDependenciesCache

        public void resetDirectDependenciesCache()
        Description copied from interface: BuildPromotionEx
        reset only direct dependencies cache of the promotion.
      • updateDependenciesCache

        public void updateDependenciesCache​(@NotNull
                                            Supplier<Map<Long,​Integer>> newDependenciesSupplier)
        Description copied from interface: BuildPromotionEx
        Updates dependencies cache of the promotion and resets "dependent on me" cache of the supplied dependencies.
      • resetDependenciesHardRefs

        public void resetDependenciesHardRefs()
        Description copied from interface: BuildPromotionEx
        Each newly created build promotion keeps a reference to its direct dependencies (BuildPromotion instances). These references are kept to avoid removal of them by GC. Once these dependencies are persisted to DB, these hard refs are no longer required. At this point this method should be called to free some memory.
      • setTagDatas

        public void setTagDatas​(@NotNull
                                Collection<TagData> tags)
        Description copied from interface: BuildPromotion
        Changes tag set for this build promotion. Attention! The whole set of tags will be replaced with new one. It means that even if new set contains only public tag the action will affect private tags as well.
        Parameters:
        tags - tags
        See Also:
        TagDataUtil, for variety of tag-releated actions
      • hasLoadedTags

        public boolean hasLoadedTags()
        Description copied from interface: BuildPromotionEx
        Returns true if promotion loaded information about tags from db
        Returns:
        see above
      • getPrivateTags

        @NotNull
        public List<String> getPrivateTags​(@NotNull
                                           SUser user)
        Description copied from interface: BuildPromotion
        Returns list of private tag labels in lexicographical order for particular user for this build promotion
        Returns:
        tags
      • getTags

        @NotNull
        public List<String> getTags()
        Description copied from interface: BuildPromotion
        Returns list of public tag labels in lexicographical order for the build promotion
        Returns:
        tags
      • setPrivateTags

        public void setPrivateTags​(@Nullable
                                   List<String> labels,
                                   @NotNull
                                   SUser user)
        Description copied from interface: BuildPromotion
        Set private tags for particular user Attention! Replace all private tags related to the particular user with new set
        Parameters:
        labels - new tag labels
        user - a particular user which tags should be updated
        See Also:
        for variety of tag-releated actions
      • getQueuedDate

        @Nullable
        public Date getQueuedDate()
        Description copied from interface: BuildPromotion
        Returns the date when the build was added to queue.
        Returns:
        queued time, null if promotion wasn't queued
      • getServerStartDate

        @Nullable
        public Date getServerStartDate()
        Description copied from interface: BuildPromotion
        Returns the timestamp when the build was removed from the queue.
        Returns:
        the timestamp when the build was removed from the queue, null if wasn't yet
      • freezeSettings

        public void freezeSettings()
                            throws IOException
        Description copied from interface: BuildPromotionEx
        Freeze buildType settings for this promotion. After call to this method a promotion will use frozen buildType settings instead of current ones.
        Throws:
        IOException - when freeze fails
      • freezeSettings

        public void freezeSettings​(@NotNull
                                   BuildTypeSettingsEx settings,
                                   @NotNull
                                   String settingsOrigin)
                            throws IOException
        Description copied from interface: BuildPromotionEx
        Freeze settings for this promotion using the given buildSettings.
        Parameters:
        settings - the settings to store into the build promotion
        settingsOrigin - origin of settings, predefined values: 'vcs' for settings from vcs, 'current' for current buildType settings
        Throws:
        IOException - when freeze fails
      • freezeSettingsWithForcedPostprocessing

        public void freezeSettingsWithForcedPostprocessing​(@NotNull
                                                           BuildTypeSettingsEx settings,
                                                           String origin)
                                                    throws IOException
        Description copied from interface: BuildPromotionEx
        Freeze settings for this promotion using the given buildSettings and mark that postprocessing is still required for this promotion.
        Parameters:
        settings - the settings to store into the build promotion
        origin - origin of settings, predefined values: 'vcs' for settings from vcs, 'current' for current buildType settings
        Throws:
        IOException - when freeze fails
      • freezeSettings

        public void freezeSettings​(@NotNull
                                   File settings,
                                   @NotNull
                                   String settingsOrigin)
                            throws IOException
        Description copied from interface: BuildPromotionEx
        Freeze settings for this promotion using the given settings file.
        Parameters:
        settings - the settings file to store into the build promotion
        settingsOrigin - origin of settings, predefined values: 'vcs' for settings from vcs, 'current' for current buildType settings
        Throws:
        IOException - when freeze fails
      • freezeSettings

        public void freezeSettings​(@NotNull
                                   BuildTypeEx buildType,
                                   @NotNull
                                   String settingsOrigin)
                            throws IOException
        Description copied from interface: BuildPromotionEx
        Freeze buildType settings for this promotion using the given buildType. After call to this method a promotion will use frozen buildType settings instead of current ones.
        Parameters:
        buildType - buildType those settings to use
        settingsOrigin - origin of settings, predefined values: 'vcs' for settings from vcs, 'current' for current buildType settings
        Throws:
        IOException - when freeze fails
      • setFreezeSettings

        public void setFreezeSettings​(@Nullable
                                      Boolean freezeSettings)
        Description copied from interface: BuildPromotionEx
        Indicates if we should freeze settings in build
        Parameters:
        freezeSettings - true means freeze settings if it is enabled for buildType, false means don't attempt to freeze settings even if they are enabled, null means use buildType's defaults (it is default value)
      • getFreezeSettings

        @Nullable
        public Boolean getFreezeSettings()
        Description copied from interface: BuildPromotionEx
        Returns true if we should freeze settings if it is enabled in buildType, false if settings shouldn't be frozen, null - use buildType's defaults
        Returns:
        see above
      • isForcedPostprocessingOfFrozenSettings

        public boolean isForcedPostprocessingOfFrozenSettings()
        Returns:
        true if settings post processing is required even if settings are already marked as frozen
      • isVcsRootsFreezeEnabled

        public static boolean isVcsRootsFreezeEnabled()
      • compareStartTime

        public static int compareStartTime​(@NotNull
                                           BuildPromotion bp1,
                                           @NotNull
                                           BuildPromotion bp2)
        Return -1 if bp1 started before bp2 and 1 otherwise
      • resetBuildSettings

        public void resetBuildSettings()
        Description copied from interface: BuildPromotionEx
        Resets cached build settings associated with promotion
      • getExecutionTimeoutMin

        public int getExecutionTimeoutMin()
        Description copied from interface: BuildPromotionEx
        Returns build execution timeout in minutes, 0 indicates that there is no limit
      • toArtifactDependency

        @NotNull
        public SArtifactDependency toArtifactDependency​(@NotNull
                                                        jetbrains.buildServer.serverSide.impl.BuildPromotionImpl.ArtifactDependencyTuple artifactDependencyTuple)
      • getBuildPromotionsWithArtifactDependenciesOnMe

        @NotNull
        public List<BuildPromotion> getBuildPromotionsWithArtifactDependenciesOnMe​(@NotNull
                                                                                   List<BuildPromotion> buildPromotions)
        Description copied from interface: BuildPromotionEx
        Checks artifact dependencies of the build promotions provided as an argument and returns those which have a direct artifact dependency (by build id) on this build promotion.
        Parameters:
        buildPromotions - build promotions to check
        Returns:
        the dependent build promotions
      • generateAgentAccessCode

        public String generateAgentAccessCode()
        Description copied from interface: BuildPromotionEx
        Generates agent access code for communication with TeamCity during build