Interface SBuild

    • Method Detail

      • getArtifactsDirectory

        @NotNull
        java.io.File getArtifactsDirectory()
                                    throws BuildTypeNotFoundException
        Returns artifacts directory of this build. Artifacts should be locked with help of ArtifactsGuard for the period of their processing.
        Returns:
        artifacts directory of this build
        Throws:
        BuildTypeNotFoundException - if build configuration of the build does not exist anymore
      • getArtifacts

        @NotNull
        BuildArtifacts getArtifacts​(@NotNull
                                    BuildArtifactsViewMode mode)
        Returns accessor for build artifacts. This accessor checks all necessary permissions for accessing files.
        Parameters:
        mode - view mode to see artifacts
        Returns:
        build artifacts viewer
      • getArtifactDependencies

        @NotNull
        java.util.List<SArtifactDependency> getArtifactDependencies()
        Returns the artifact dependencies of this build. Same as getBuildPromotion().getArtifactDependencies().
        Returns:
        artifact dependencies
      • isHasInternalArtifactsOnly

        boolean isHasInternalArtifactsOnly()
        Returns true if this build has only internal (hidden) artifacts.
        Returns:
        true if this build has internal artifacts only
        Since:
        7.0
        See Also:
        isArtifactsExists()
      • isResponsibleNeeded

        boolean isResponsibleNeeded()
        Always returns false for personal and/or cancelled builds. Returns true if this build is failed (or failing) and there are no finished successful builds after this build. Returns true even if there is active responsible for the build configuration but the configuration status is failed.
        Returns:
        see above.
      • getBuildLog

        @NotNull
        BuildLog getBuildLog()
        Returns build log.
        Returns:
        build log.
      • hasTests

        boolean hasTests()
        Returns:
        true if this build has tests (for composite, returns true if at least one dependency has a test)
        Since:
        2021.2
      • getOwner

        @Nullable
        SUser getOwner()
        If this build is personal one, returns the owner of this build.
        Returns:
        null if this build is not personal otherwise owner of this build
        See Also:
        Build.isPersonal()
      • getTriggeredBy

        @NotNull
        TriggeredBy getTriggeredBy()
        Returns details about how this build was triggered.
        Returns:
        see above
      • getBuildType

        @Nullable
        SBuildType getBuildType()
        Returns build configuration this build belongs to.
        Specified by:
        getBuildType in interface Build
        Returns:
        build configuration descriptor.
      • getDownloadedArtifacts

        @NotNull
        DownloadedArtifacts getDownloadedArtifacts()
        Returns information about artifacts downloaded by this build according to configured artifact dependencies.
        Returns:
        information about downloaded artifacts.
      • getProvidedArtifacts

        @NotNull
        DownloadedArtifacts getProvidedArtifacts()
        Returns information about provided artifacts, i.e. artifacts that were downloaded from this build by other builds by artifact dependencies.
        Returns:
        see above
      • isUsedByOtherBuilds

        boolean isUsedByOtherBuilds()
        Returns true if this build is used by other builds, i.e. there are dependencies by sources on this build or artifacts of this build were downloaded by other builds.
        Returns:
        see above
      • getContainingChanges

        @NotNull
        java.util.List<SVcsModification> getContainingChanges()
        Description copied from interface: Build
        Returns changes in this build. Same as getChanges(SelectPrevBuildPolicy.SINCE_LAST_BUILD, false) Ordering: last detected modifications goes first in the list
        Specified by:
        getContainingChanges in interface Build
        Returns:
        changes in this build
      • getChanges

        @NotNull
        java.util.List<SVcsModification> getChanges​(@NotNull
                                                    SelectPrevBuildPolicy policy,
                                                    boolean includeModificationsIfPreviousBuildIsAbsent)
        Description copied from interface: Build
        List of modifications detected in the version control since the previous build (selected according to the specified policy) Ordering: last detected modifications goes first in the list
        Specified by:
        getChanges in interface Build
        Parameters:
        policy - can be one of the two kinds:
        includeModificationsIfPreviousBuildIsAbsent - should the method return something if there's no previous build.
        Returns:
        list of modifications
      • isOutOfChangesSequence

        boolean isOutOfChangesSequence()
        Returns true if there is a build started before but having more recent changes then this build. Such situation can occur if this build was associated with a specific change list before adding to queue at the time when more recent changes were available.
        Returns:
        see above
      • getTags

        java.util.List<java.lang.String> getTags()
        Returns list of public tags for this build
        Returns:
        tags
      • setTags

        void setTags​(java.util.List<java.lang.String> tags)
        Sets public tags for this build
        Parameters:
        tags - tags to set
      • setTags

        @Deprecated
        void setTags​(User user,
                     java.util.List<java.lang.String> tags)
        Deprecated.
        Use {@link #setTags(List)) {@link #getBuildPromotion().setTags(List)), user will be retrieved from context
        Sets public tags for this build
        Parameters:
        user - user who set tags, this user is not treated as tag owner - the user from security context, doesn't correspond to tags owner
        tags - tag labels to set
        Since:
        4.0.1
      • getFileContent

        @NotNull
        byte[] getFileContent​(java.lang.String filePath)
                       throws VcsException
        Get binary content of the single file related to this build.
        Parameters:
        filePath - - relative file path regarding to the project root, "checkout root" from vcs root should not be included
        Returns:
        - specified file content, corresponding to the build
        Throws:
        VcsException - if some problem occurred while getting file content from the source control repository.
      • getRevisions

        java.util.List<BuildRevision> getRevisions()
        List of all revisions which were used for the build instance
        Returns:
        all revisions which were used in this build
      • getLabels

        java.util.List<VcsLabel> getLabels()
        VCS labels which were made by TeamCity for the build. If label attempt fails VcsLabel status is FAILED and failureReason contains short description of the problem.
        Returns:
        VCS labels which were made by TeamCity for the build
      • getQueuedDate

        @NotNull
        java.util.Date getQueuedDate()
        Returns the date when the build was added to queue.
        Returns:
        queued time.
      • getServerStartDate

        @NotNull
        java.util.Date getServerStartDate()
        Returns the timestamp when the build was removed from the queue.
        Returns:
        the timestamp when the build was removed from the queue.
      • getVcsRootEntries

        java.util.List<VcsRootInstanceEntry> getVcsRootEntries()
        Returns vcs roots with checkout rules for the build start moment.
        Returns:
        vcs roots with checkout rules for the build start moment.
      • getClientStartDate

        @Nullable
        java.util.Date getClientStartDate()
        Returns the timestamp when the build was started on the build agent (in agent time)
        Returns:
        the timestamp when the build was started on the build agent (in agent time)
      • isStartedOnAgent

        boolean isStartedOnAgent()
        Returns true if this build was started on agent.
        Returns:
        see above
      • convertToServerTime

        @NotNull
        java.util.Date convertToServerTime​(@NotNull
                                           java.util.Date agentTime)
        Converts agent time to server time by taking into account agent and server time difference.
        Parameters:
        agentTime - time on agent
        Returns:
        server time
      • convertToAgentTime

        @NotNull
        java.util.Date convertToAgentTime​(@NotNull
                                          java.util.Date serverTime)
        Converts server time to agent time by taking into account agent and server time difference.
        Parameters:
        serverTime - server time to convert
        Returns:
        agent time
      • getBuildDescription

        @Nullable
        java.lang.String getBuildDescription()
        Returns build description set to this build explicitly or null.
        Returns:
        see above
      • getValueResolver

        @NotNull
        ValueResolver getValueResolver()
        Returns build-aware value resolver to be used to resolve values based on the build's properties.
        Specified by:
        getValueResolver in interface ParametersSupport
        Returns:
        this build-aware value resolver
      • getBuildComment

        @Nullable
        Comment getBuildComment()
        Returns build comment.
        Returns:
        build comment, or null if this build is not commented.
      • setBuildComment

        void setBuildComment​(@Nullable
                             User user,
                             @Nullable
                             java.lang.String comment)
        Sets the comment for the build
        Parameters:
        user - user who sets the comment
        comment - text of the comment
      • isPinned

        boolean isPinned()
        Returns true if this build is pinned
        Returns:
        true if this build is pinned
      • getRelatedIssues

        @NotNull
        java.util.Collection<Issue> getRelatedIssues()
        Returns the collection of related issues (e.g. mentioned in modification's comments, or mentioned in the build's comment).
        Returns:
        related issues
        Since:
        5.0
        See Also:
        isHasRelatedIssues(), SVcsModification.getRelatedIssues()
      • isHasRelatedIssues

        boolean isHasRelatedIssues()
        Returns whether the build has related issues (e.g. mentioned in modification's comments, or mentioned in the build's comment).
        Returns:
        true if the build has related issues
        Since:
        7.0
        See Also:
        getRelatedIssues(), SVcsModification.isHasRelatedIssues()
      • getBuildOwnParameters

        @NotNull
        java.util.Map<java.lang.String,​java.lang.String> getBuildOwnParameters()
        Returns map of parameters (configuration params, system properties and environment variables) excluding parameters provided by extensions.
        Returns:
        see above
        Since:
        5.0
      • getRawBuildNumber

        java.lang.String getRawBuildNumber()
        Returns raw build number (i.e. build number with unresolved parameters if they exist) in contradistinction to Build.getBuildNumber() method which will return build number with all unresolved parameters replaced with ???.
        Returns:
        raw build number which can contain unresolved parameters
        Since:
        5.0
      • isInternalError

        boolean isInternalError()
        Returns whether this build failed because of internal error (infrastructural error not related to build script).
        Returns:
        true iff the build is error
        Since:
        6.0
      • getFirstInternalError

        @Nullable
        java.lang.String getFirstInternalError()
        Returns the first internal error in a build, or null.
        Returns:
        first internal error type
        Since:
        6.0
      • getFirstInternalErrorMessage

        @Nullable
        java.lang.String getFirstInternalErrorMessage()
        Returns the error message associated with the first internal error, or null
        Returns:
        first internal error message
        Since:
        6.0
      • getClientTimeZone

        @Nullable
        java.util.TimeZone getClientTimeZone()
        Returns agent machine time zone if it's available on server.
        Returns:
        Agent time zone or null if the build wasn't started yet.
        Since:
        7.0
      • getAgent

        @NotNull
        SBuildAgent getAgent()
        Returns:
        agent where this build executed.
        Since:
        7.0
      • addBuildProblem

        void addBuildProblem​(@NotNull
                             BuildProblemData buildProblem)
        Adds build problem to the build. Currently build problem causes build failure.
        Since:
        7.1
      • hasBuildProblemOfType

        boolean hasBuildProblemOfType​(@NotNull
                                      java.lang.String type)
        Returns true if build has build problem of this type
        Parameters:
        type - build problem type
        Returns:
        see above
        Since:
        7.1
        See Also:
        BuildProblemData
      • getFailureReasons

        @NotNull
        java.util.List<BuildProblemData> getFailureReasons()
        Returns build problems that caused build failure or empty list if build is successful
        Returns:
        see above
        Since:
        7.1
      • muteBuildProblems

        void muteBuildProblems​(@NotNull
                               SUser user,
                               boolean muteIfTrue,
                               @NotNull
                               java.lang.String comment)
        Makes all existing build problems enabled or disabled
        Parameters:
        user - user that will be used in audit
        muteIfTrue - pass true to make build successful, false to make existing problems visible again
        comment - comment for audit
        Since:
        7.1
      • addUserBuildProblem

        BuildProblemData addUserBuildProblem​(@NotNull
                                             SUser user,
                                             @NotNull
                                             java.lang.String problemDescription)
        Adds user provided build problem to the build. Currently build problem causes build failure. Adding user provided problem always overrides previously added one
        Parameters:
        user - user that will be used in audit
        Returns:
        added build problem
        Since:
        7.1
      • getBranch

        @Nullable
        Branch getBranch()
        Returns:
        branch associated with this build or null.
        Since:
        7.1
      • getPreviousFinished

        @Nullable
        SFinishedBuild getPreviousFinished()
        Returns:
        returns previous finished build (ordered by changes). If this build is personal, this method can return previous personal build, otherwise only regular builds are returned.
        Since:
        7.1
      • getStatisticValue

        @Nullable
        java.math.BigDecimal getStatisticValue​(java.lang.String valueTypeKey)
        Parameters:
        valueTypeKey - ValueType key to lookup. Eg TimeSpentInQueue, ArtifactsSize, DuplicatorStats CodeCoverageB, CodeCoverageC or any custom build statistic value reported by service message during the build.
        Returns:
        Value of specified ValueType. Null when specified value wasn't produced during the build (eg no artifacts produced for ArtifactsSize key) or key is invalid.
        Since:
        8.0
        See Also:
        ValueProviderRegistry
      • getStatisticValues

        @NotNull
        java.util.Map<java.lang.String,​java.math.BigDecimal> getStatisticValues()
        Returns:
        All statistics values associated with this build. Includes all predefined ValueTypes reported for this build and custom metrics reported by service message during the build as well (even when there is no ValueType defined for the metric).
        Since:
        8.0
      • getBuildFeaturesOfType

        @NotNull
        java.util.Collection<SBuildFeatureDescriptor> getBuildFeaturesOfType​(@NotNull
                                                                             java.lang.String featureType)
        Returns collection of enabled and resolved build features of specified type from build settings (resolving is performed at the moment of the method call).
        Parameters:
        featureType - type of the build feature
        Returns:
        see above
        Since:
        9.0
      • isOutdated

        boolean isOutdated()
        Returns true if this build is outdated. The build is considered outdated if there is a finished non-personal build which contains newer (or same) changes as contained in this build.
        Returns:
        see above
        Since:
        2017.2
      • getRecentlyFinishedBuild

        @Nullable
        SFinishedBuild getRecentlyFinishedBuild()
        Returns:
        the build because of which this running build has been marked as outdated (see isOutdated()).
        Since:
        2017.2
      • isAgentLessBuild

        boolean isAgentLessBuild()
        Returns:
        true if this build does not require an agent (for now this is true for composite builds only)
        Since:
        2017.2
      • isCompositeBuild

        boolean isCompositeBuild()
        Returns true if this build is a composite build.
        Returns:
        see above
        Since:
        2020.1
      • isDetachedFromAgent

        boolean isDetachedFromAgent()
        Returns true if this build was detached from agent at some point.
        Returns:
        see above
        Since:
        2020.2
      • getFinishOnAgentDate

        @Nullable
        java.util.Date getFinishOnAgentDate()
        Returns timestamp when the build finished on agent (server time) or null if it is still running on agent.
        Returns:
        see above
        Since:
        2020.2
      • getCustomDataStorage

        @NotNull
        CustomDataStorage getCustomDataStorage​(@NotNull
                                               java.lang.String key)
        Returns a data storage which can be used to associate arbitrary data with the build.
        Parameters:
        key - a key to access the storage
        Returns:
        an existing or newly created storage for the given key
        Since:
        2022.04
      • getRemoteArtifacts

        @NotNull
        java.util.List<RemoteArtifacts> getRemoteArtifacts()
        Returns list of all remote artifacts that were published for this build.
        Returns:
        collection of RemoteArtifact
        Since:
        2022.08
      • getRemoteArtifactsByType

        @NotNull
        RemoteArtifacts getRemoteArtifactsByType​(@NotNull
                                                 java.lang.String type)
        Returns list of remote artifacts that belong to a specific type.
        Returns:
        collection of RemoteArtifact
        Since:
        2022.08
      • getWaitReasons

        @NotNull
        java.util.Map<java.lang.String,​java.lang.Long> getWaitReasons()
        Returns wait reasons for this build, while it was in the build queue. The key of the map is a wait reason description in human friendly form. The value is amount of milliseconds this wait reason was reported for this queued build.
        Returns:
        map of a wait reason to amount of time it was reported for the build in milliseconds
        Since:
        2023.03