Package hudson.model

Class AbstractBuild<P extends AbstractProject<P,​R>,​R extends AbstractBuild<P,​R>>

    • Method Detail

      • getProject

        public final P getProject()
      • getBuiltOn

        @CheckForNull
        public Node getBuiltOn()
        Returns a Slave on which this build was done.
        Returns:
        null, for example if the agent that this build run no longer exists.
      • getBuiltOnStr

        @Exported(name="builtOn")
        public String getBuiltOnStr()
        Returns the name of the agent it was built on; null or "" if built by the built-in node. (null happens when we read old record that didn't have this information.)
      • setBuiltOnStr

        protected void setBuiltOnStr​(String builtOn)
        Allows subtypes to set the value of builtOn. This is used for those implementations where an AbstractBuild is made 'built' without actually running its run() method.
        Since:
        1.429
      • getRootBuild

        public AbstractBuild<?,​?> getRootBuild()
        Gets the nearest ancestor AbstractBuild that belongs to the root project of getProject() that dominates/governs/encompasses this build.

        Some projects (such as matrix projects, Maven projects, or promotion processes) form a tree of jobs, and still in some of them, builds of child projects are related/tied to that of the parent project. In such a case, this method returns the governing build.

        Returns:
        never null. In the worst case the build dominates itself.
        Since:
        1.421
        See Also:
        AbstractProject.getRootProject()
      • getParentExecutable

        public Queue.Executable getParentExecutable()
        Description copied from interface: Queue.Executable
        An umbrella executable (such as a Run) of which this is one part. Some invariants:
        • getParent().getOwnerTask() == getParent() || getParentExecutable().getParent() == getParent().getOwnerTask()
        • getParent().getOwnerExecutable() == null || getParentExecutable() == getParent().getOwnerExecutable()
        Specified by:
        getParentExecutable in interface Queue.Executable
        Returns:
        a distinct executable (never this, unlike the default of SubTask.getOwnerTask()!); or null if this executable was already at top level
        See Also:
        SubTask.getOwnerExecutable()
      • getUpUrl

        @Deprecated(since="2.364")
        public String getUpUrl()
        Deprecated.
        navigation through a hierarchy should be done through breadcrumbs, do not add a link using this method
        Used to render the side panel "Back to project" link.

        In a rare situation where a build can be reached from multiple paths, returning different URLs from this method based on situations might be desirable.

        If you override this method, you'll most likely also want to override Run.getDisplayName().

      • getWorkspace

        @CheckForNull
        public final FilePath getWorkspace()
        Gets the directory where this build is being built.

        Note to implementors: to control where the workspace is created, override AbstractBuild.AbstractBuildExecution.decideWorkspace(Node,WorkspaceList).

        Returns:
        null if the workspace is on an agent that's not connected. Note that once the build is completed, the workspace may be used to build something else, so the value returned from this method may no longer show a workspace as it was used for this build.
        Since:
        1.319
      • setWorkspace

        protected void setWorkspace​(@NonNull
                                    FilePath ws)
        Normally, a workspace is assigned by Run.RunExecution, but this lets you set the workspace in case AbstractBuild is created without a build.
      • getModuleRoot

        public final FilePath getModuleRoot()
        Returns the root directory of the checked-out module.

        This is usually where pom.xml, build.xml and so on exists.

      • getModuleRoots

        public FilePath[] getModuleRoots()
        Returns the root directories of all checked-out modules.

        Some SCMs support checking out multiple modules into the same workspace. In these cases, the returned array will have a length greater than one.

        Returns:
        The roots of all modules checked out from the SCM.
      • getCulprits

        @Exported
        @NonNull
        public Set<User> getCulprits()
        Description copied from interface: RunWithSCM
        List of users who committed a change since the last non-broken build till now.

        This list at least always include people who made changes in this build, but if the previous build was a failure it also includes the culprit list from there.

        Missing Users will be created on-demand.

        Specified by:
        getCulprits in interface RunWithSCM<P extends AbstractProject<P,​R>,​R extends AbstractBuild<P,​R>>
        Returns:
        can be empty but never null.
      • getHudsonVersion

        public String getHudsonVersion()
        Gets the version of Hudson that was used to build this job.
        Since:
        1.246
      • getChangeSet

        @Exported
        @NonNull
        public ChangeLogSet<? extends ChangeLogSet.Entry> getChangeSet()
        Gets the changes incorporated into this build.
        Returns:
        never null.
      • hasChangeSetComputed

        public boolean hasChangeSetComputed()
        Returns true if the changelog is already computed.
      • getEnvironments

        public EnvironmentList getEnvironments()
        During the build, expose the environments contributed by BuildWrappers and others.

        Since 1.444, executor thread that's doing the build can access mutable underlying list, which allows the caller to add/remove environments. The recommended way of adding environment is through BuildWrapper, but this might be handy for build steps who wants to expose additional environment variables to the rest of the build.

        Returns:
        can be empty list, but never null. Immutable.
        Since:
        1.437
      • addAction

        public void addAction​(@NonNull
                              Action a)
        Adds a new action. Note: calls to Actionable.getAllActions() that happen before calls to this method may not see the update. Note: this method will always modify the actions A RunAction2 is handled specially. The action may have a summary.jelly view containing a <t:summary> or other <tr>.
        Overrides:
        addAction in class Run<P extends AbstractProject<P,​R>,​R extends AbstractBuild<P,​R>>
      • getPersistentActions

        public List<Action> getPersistentActions()
      • getSensitiveBuildVariables

        public Set<String> getSensitiveBuildVariables()
        Builds up a set of variable names that contain sensitive values that should not be exposed. The expectation is that this set is populated with keys returned by getBuildVariables() that should have their values masked for display purposes.
        Since:
        1.378
      • getBuildVariables

        public Map<String,​String> getBuildVariables()
        Provides additional variables and their values to Builders.

        This mechanism is used by MatrixConfiguration to pass the configuration values to the current build. It is up to Builders to decide whether they want to recognize the values or how to use them.

        This also includes build parameters if a build is parameterized.

        Returns:
        The returned map is mutable so that subtypes can put more values.
      • getDownstreamRelationship

        public Fingerprint.RangeSet getDownstreamRelationship​(AbstractProject that)
        Gets the dependency relationship from this build (as the source) and that project (as the sink.)
        Returns:
        range of build numbers that represent which downstream builds are using this build. The range will be empty if no build of that project matches this (or there is no Fingerprinter.FingerprintAction), but it'll never be null.
      • getUpstreamRelationship

        public int getUpstreamRelationship​(AbstractProject that)
        Gets the dependency relationship from this build (as the sink) and that project (as the source.)
        Returns:
        Build number of the upstream build that feed into this build, or -1 if no record is available (for example if there is no Fingerprinter.FingerprintAction, even if there is an Cause.UpstreamCause).
      • getDownstreamBuilds

        public Map<AbstractProject,​Fingerprint.RangeSet> getDownstreamBuilds()
        Gets the downstream builds of this build, which are the builds of the downstream projects that use artifacts of this build.
        Returns:
        For each project with fingerprinting enabled, returns the range of builds (which can be empty if no build uses the artifact from this build or downstream is not AbstractProject.isFingerprintConfigured().)
      • doStop

        @Deprecated
        public void doStop​(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException
        Deprecated.
        as of 1.489 Use doStop()
        Throws:
        IOException
        javax.servlet.ServletException
      • doStop

        public org.kohsuke.stapler.HttpResponse doStop()
                                                throws IOException,
                                                       javax.servlet.ServletException
        Stops this build if it's still going. If we use this/executor/stop URL, it causes 404 if the build is already killed, as Run.getExecutor() returns null.
        Throws:
        IOException
        javax.servlet.ServletException
        Since:
        1.489