Class RunningBuildImpl

    • Method Detail

      • initialize

        protected void initialize​(boolean newBuild)
      • prepareArtifactDependencies

        public void prepareArtifactDependencies()
        Description copied from interface: RunningBuildEx
        Resolves artifact dependencies by replacing "latest" rules with actual build ids.
        Specified by:
        prepareArtifactDependencies in interface RunningBuildEx
      • computeAgentlessBuildAgent

        @NotNull
        public BuildAgentEx computeAgentlessBuildAgent()
      • getQueuedAgentId

        public Integer getQueuedAgentId()
        Specified by:
        getQueuedAgentId in interface SRunningBuild
        Returns:
        agent this build was queued on or null if build was not queued on a specific agent
      • getProgressText

        @NotNull
        public String getProgressText()
        Specified by:
        getProgressText in interface RunningBuildEx
        Returns:
        current progress text calculated for the build; this text is used in build status line
      • getCurrentPath

        public String getCurrentPath()
        Description copied from interface: SRunningBuild
        Returns short description of current running step.
        Specified by:
        getCurrentPath in interface SRunningBuild
        Returns:
        short description of current running step.
      • getFinishDate

        @Nullable
        public Date getFinishDate()
        Description copied from interface: Build
        Returns finish timestamp for the build (server time) or null if it hasn't been finished yet.
        Specified by:
        getFinishDate in interface Build
        Returns:
        Date/time when the build has been finished, null if still running.
      • runUnlessFinished

        public boolean runUnlessFinished​(@NotNull
                                         Runnable action)
        Description copied from interface: RunningBuildEx
        Executes specified runnable if build is not finished. Build won't finish until runnable completes.
        Specified by:
        runUnlessFinished in interface RunningBuildEx
        Parameters:
        action - runnable
        Returns:
        true if runnable was executed
      • getStatusDescriptor

        public StatusDescriptor getStatusDescriptor()
        Description copied from interface: Build
        Returns status descriptor of the build
        Specified by:
        getStatusDescriptor in interface Build
        Returns:
        Descriptor of the current status of the build
      • getCachedShortStatistics

        @Nullable
        public ShortStatistics getCachedShortStatistics​(boolean calculateIfAbsent)
        Description copied from interface: BuildEx
        Return cached short statistics for this build.
        Specified by:
        getCachedShortStatistics in interface BuildEx
        Parameters:
        calculateIfAbsent - if true, then statistics is calculated if it is not cached yet, if false and there is no statistics in cache, then null is returned
        Returns:
        see above
      • updateBuildInfo

        public boolean updateBuildInfo()
        Description copied from interface: RunningBuildEx
        Loads build interruption and build finish timestamps from database into the build. Returns true if running build exists in DB and false otherwise.
        Specified by:
        updateBuildInfo in interface RunningBuildEx
      • clearCachedEstimate

        @TestOnly
        public void clearCachedEstimate()
      • getProjectId

        @Nullable
        public String getProjectId()
        Description copied from interface: Build
        Returns internal id of the project this build belongs to. Same as getBuildType().getProjectId().
        Specified by:
        getProjectId in interface Build
        Returns:
        internal id of the project this build belongs to. Same as getBuildType().getProjectId().
      • getProjectExternalId

        @Nullable
        public String getProjectExternalId()
        Description copied from interface: Build
        Returns external id of the project this build belongs to. Same as getBuildType().getProjectId().
        Specified by:
        getProjectExternalId in interface Build
        Returns:
        external id of the project this build belongs to. Same as getBuildType().getProjectId().
      • getAgentName

        @NotNull
        public String getAgentName()
        Description copied from interface: Build
        Returns agent name where build is running or happened to run if finished.
        Specified by:
        getAgentName in interface Build
        Returns:
        Agent name where build has been started on
      • setStartTimes

        public void setStartTimes​(@NotNull
                                  Date agentStartTime,
                                  @NotNull
                                  Date serverStartTime,
                                  @NotNull
                                  TimeZone agentTimeZone)
        Description copied from interface: RunningBuildEx
        Sets timestamps when command to run build was sent to an agent.
        Specified by:
        setStartTimes in interface RunningBuildEx
        Parameters:
        agentStartTime - agent timestamp
        serverStartTime - server timestamp
      • getCompletedPercent

        public int getCompletedPercent()
        Specified by:
        getCompletedPercent in interface SRunningBuild
        Returns:
        completed percentage for the build according to build duration estimated time. or -1 if there is no estimate
      • getCompletedPercent

        public int getCompletedPercent​(long currentTime)
      • occupiesAgent

        public boolean occupiesAgent()
        Specified by:
        occupiesAgent in interface RunningBuildInfo
        Returns:
        true if the build executes on the agent.
      • getEstimationForTimeLeft

        public long getEstimationForTimeLeft​(long currentTime)
      • isFinishReceived

        public boolean isFinishReceived()
        Specified by:
        isFinishReceived in interface RunningBuildEx
        Returns:
        true if build finished was received by the server.
      • publishArtifact

        public final void publishArtifact​(@NotNull
                                          String path,
                                          @NotNull
                                          byte[] content)
                                   throws IOException
        Description copied from interface: RunningBuildEx
        Adds artifact to the build by the specified path
        Specified by:
        publishArtifact in interface RunningBuildEx
        Parameters:
        path - path where to store artifact
        content - artifact content
        Throws:
        IOException
      • publishArtifact

        public final void publishArtifact​(@NotNull
                                          String path,
                                          @NotNull
                                          File srcFile)
                                   throws IOException
        Description copied from interface: RunningBuildEx
        Adds artifact to the build by the specified path
        Specified by:
        publishArtifact in interface RunningBuildEx
        Parameters:
        path - path where to store artifact
        srcFile - file containing artifact content; note that after the publishing srcFile can be removed
        Throws:
        IOException
      • publishArtifact

        public final void publishArtifact​(@NotNull
                                          String path,
                                          @NotNull
                                          File srcFile,
                                          @Nullable
                                          PublishArtifactProgressListener progressListener)
                                   throws IOException
        Description copied from interface: RunningBuildEx
        Adds artifact to the build from the specified file allowing to trace progress
        Specified by:
        publishArtifact in interface RunningBuildEx
        Parameters:
        path - path where to store artifact
        srcFile - file containing artifact content; note that after the publishing srcFile can be removed
        progressListener - PublishArtifactProgressListener to track progress
        Throws:
        IOException
      • getDurationEstimate

        public long getDurationEstimate()
        Description copied from interface: RunningBuild
        Returns server estimation for this build duration in seconds.
        Specified by:
        getDurationEstimate in interface RunningBuild
        Returns:
        build duration estimation in seconds or -1 if estimate is not available.
      • getDurationOvertime

        public long getDurationOvertime()
        Description copied from interface: RunningBuild
        Returns how much in seconds this build duration exceeded estimated duration.
        Specified by:
        getDurationOvertime in interface RunningBuild
        Returns:
        how much in seconds this build duration exceeded estimated duration or -1 if estimate is not available.
      • getEstimatedDurationExceededTime

        public long getEstimatedDurationExceededTime​(long currentTime)
      • getElapsedTime

        public long getElapsedTime()
        Description copied from interface: RunningBuild
        Returns elapsed time for this build.
        Specified by:
        getElapsedTime in interface RunningBuild
        Returns:
        elapsed time for this build in seconds.
      • getElapsedTime

        public long getElapsedTime​(long currentTime)
      • getBuildNumber

        @NotNull
        public String getBuildNumber()
        Description copied from interface: Build
        Returns build number in the user defined format (unresolved parameters in build number will be replaced with '???').
        Specified by:
        getBuildNumber in interface Build
        Returns:
        presentable build number
      • setBuildNumber

        public void setBuildNumber​(@NotNull
                                   String newBuildNumber)
        Description copied from interface: SRunningBuild
        Set new value for this build build number instead of current one. If newBuildNumber has pattern {build.number}, it is replaced with the current build number
        Specified by:
        setBuildNumber in interface SRunningBuild
        Parameters:
        newBuildNumber - new value for this build build number
      • getTestMessages

        public List<TestInfo> getTestMessages​(int skipTests,
                                              int maxTestsToLoad)
        Description copied from interface: Build
        Retrieves information about tests failed in the build. Note that for running build currently executing test will be added to the list too.
        Specified by:
        getTestMessages in interface Build
        Overrides:
        getTestMessages in class BaseBuild
        Parameters:
        skipTests - index/order number of the first test to load (zero based)
        maxTestsToLoad - indicates how many tests to load, -1 to load all
        Returns:
        list of plain messages
      • isFinished

        public boolean isFinished()
        Specified by:
        isFinished in interface Build
        Returns:
        true if the build was finished and was saved to the history
      • getAgentAccessCode

        public String getAgentAccessCode()
        Description copied from interface: SRunningBuild
        Returns access code which can be used by agent to access server resources by HTTP.
        Specified by:
        getAgentAccessCode in interface SRunningBuild
        Returns:
        access code
      • getRawBuildNumber

        public String getRawBuildNumber()
        Description copied from interface: SBuild
        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 ???.
        Specified by:
        getRawBuildNumber in interface SBuild
        Specified by:
        getRawBuildNumber in class BaseBuild
        Returns:
        raw build number which can contain unresolved parameters
      • isProbablyHanging

        public boolean isProbablyHanging()
        Description copied from interface: SRunningBuild
        Returns true if server thinks this build has hung. The build is considered hung if its estimate is exceeded and there were no messages from this build for some time.
        Specified by:
        isProbablyHanging in interface SRunningBuild
        Returns:
        true if build is probably hanging
      • computeProbablyHanging

        public boolean computeProbablyHanging​(long currentTime)
      • start

        public void start​(boolean async)
        Description copied from interface: RunningBuildEx
        Must be invoked only once when build starts.
        Specified by:
        start in interface RunningBuildEx
      • isStarting

        public boolean isStarting()
        Description copied from interface: RunningBuildEx
        Returns true if the build is trying to start on an agent and runBuild() command has not finished yet
        Specified by:
        isStarting in interface RunningBuildEx
        Returns:
      • stop

        public void stop​(@NotNull
                         RunningBuildState interruptedState,
                         @Nullable
                         User user,
                         @NotNull
                         String comment,
                         boolean reAdd2Queue)
        Specified by:
        stop in interface RunningBuildEx
        Parameters:
        interruptedState - how to interrupt the build, should have interrupted status
        user - optional user who stops the build
        comment - comment for build interruption
        reAdd2Queue - if true, the build will be re-added to queue with the same build promotion (to the end of the queue)
      • finish

        public void finish​(@NotNull
                           Date finishDate)
        Description copied from interface: SRunningBuild
        Finalizes all build related activities and finishes the build. Build must be finished on agent. Takes no effect for already finished or interrupted builds.
        Specified by:
        finish in interface SRunningBuild
        Parameters:
        finishDate - finish date
      • stopNoInterrupt

        public final void stopNoInterrupt()
        Description copied from interface: RunningBuildEx
        Stops build on server and on agent without making it interrupted
        Specified by:
        stopNoInterrupt in interface RunningBuildEx
      • getAgentId

        public int getAgentId()
        Specified by:
        getAgentId in interface SRunningBuild
        Returns:
        id of the agent where this build is running; returns -1 for agent less builds
      • getBuildOwnParameters

        @NotNull
        public Map<String,​String> getBuildOwnParameters()
        Description copied from interface: SBuild
        Returns map of parameters (configuration params, system properties and environment variables) excluding parameters provided by extensions.
        Specified by:
        getBuildOwnParameters in interface SBuild
        Overrides:
        getBuildOwnParameters in class BaseBuild
        Returns:
        set of build parameters known on the server-side for the build.
      • getTestRunMuter

        @NotNull
        public TestRunMuter getTestRunMuter()
        Description copied from interface: RunningBuildEx
        Returns a special service that allows to mute test run if neccessary.
        Specified by:
        getTestRunMuter in interface RunningBuildEx
        Returns:
        an instance of the test run muter.
      • getUserDataStorage

        @NotNull
        public UserDataStorage getUserDataStorage()
        Description copied from interface: RunningBuildEx
        Use this object to associate some data with the current instance. Stored data is not persisted and is not copied to another instance of the given object.
        Specified by:
        getUserDataStorage in interface RunningBuildEx
        Returns:
        user data holder
      • setBuildStatus

        public void setBuildStatus​(Status status)
        Description copied from interface: SRunningBuild
        Set current status of the running build. Useful before build finish to update build status.
        Specified by:
        setBuildStatus in interface SRunningBuild
        Parameters:
        status - new status of the build
      • muteBuildProblems

        public void muteBuildProblems​(boolean muteIfTrue)
        Description copied from interface: BuildEx
        Makes all existing build problems enabled or disabled
        Specified by:
        muteBuildProblems in interface BuildEx
        Overrides:
        muteBuildProblems in class BaseBuild
        Parameters:
        muteIfTrue - pass true to make build successful, false to make existing problems visible again
      • isCompositeBuild

        public boolean isCompositeBuild()
        Description copied from interface: SBuild
        Returns true if this build is a composite build.
        Specified by:
        isCompositeBuild in interface SBuild
        Returns:
        see above
      • closeBuildLog

        public void closeBuildLog()
        Description copied from interface: RunningBuildEx
        Closes the build log's root block, flushes messages and closes the build log
        Specified by:
        closeBuildLog in interface RunningBuildEx
      • detachedFromAgent

        public void detachedFromAgent()
        Description copied from interface: RunningBuildEx
        Should be called when the build has been detached from the agent and agent can start some other build
        Specified by:
        detachedFromAgent in interface RunningBuildEx