IBuildInfo

public interface IBuildInfo

com.android.tradefed.build.IBuildInfo


Holds information about the build under test.

Summary

Constants

String REMOTE_FILE_PREFIX

Prefix used in name to indicate the file is set to be delayed download.

String REMOTE_FILE_VERSION

Remote file is not versioned.

String UNKNOWN_BUILD_ID

Default value when build ID is unknown.

Public methods

default void addAppPackageFile(File appPackageFile, String version)

Adds the local apk file and its associated version.

abstract void addBuildAttribute(String attributeName, String attributeValue)

Add a build attribute.

default void addBuildAttributes( buildAttributes)

Add build attributes

default void allowStagingRemoteFile(boolean stageRemoteFile)

Sets permission to allow staging remote files.

abstract void cleanUp()

Clean up any temporary build files

abstract void cleanUp( doNotDelete)

Version of cleanUp() where some files are not deleted.

abstract IBuildInfo clone()

Clones the IBuildInfo object.

default getAppPackageFiles()

Gets a copy of the set of local app apk file(s) and their versions.

abstract getBuildAttributes()

Get a set of name-value pairs of additional attributes describing the build.

abstract String getBuildBranch()

Optional method to return the source control branch that the build being tested was produced from.

abstract String getBuildFlavor()

Optional method to return the type of build being tested.

abstract String getBuildId()

Returns the unique identifier of build under test.

abstract String getBuildTargetName()

Return complete name for the build being tested.

abstract String getDeviceSerial()
abstract File getFile(String name)

Helper method to retrieve a file with given name.

default File getFile(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file with given a BuildInfoFileKey.

abstract getFiles()

Returns all VersionedFiles stored in this BuildInfo.

abstract getProperties()

Returns a copy of the properties currently set on the IBuildInfo.

default getRemoteFiles()

Get the paths for build artifacts that are delayed download.

abstract String getTestTag()

Return a unique name for the tests being run.

default String getVersion(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file version with given a BuildInfoFileKey.

abstract String getVersion(String name)

Helper method to retrieve a file version with given name.

default VersionedFile getVersionedFile(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a VersionedFile with a given BuildInfoFileKey.

default VersionedFile getVersionedFile(String name)

Helper method to retrieve a VersionedFile with a given name.

default getVersionedFileKeys()

Returns the set of keys available to query VersionedFile via getFile(BuildInfoFileKey).

default getVersionedFiles(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a list of VersionedFiles associated with a given BuildInfoFileKey.

default void removeBuildAttribute(String attributeName)

Remove a given attributeName from tracking.

abstract void setBuildBranch(String branch)

Set the build branch

abstract void setBuildFlavor(String buildFlavor)

Set the build flavor.

abstract void setBuildId(String buildId)

Sets the unique identifier of build under test.

abstract void setDeviceSerial(String serial)

Set the ITestDevice serial associated with this build.

abstract void setFile(String name, File file, String version)

Stores an file with given name in this build info.

default void setFile(BuildInfoKey.BuildInfoFileKey key, File file, String version)

Stores an file given a BuildInfoFileKey in this build info.

abstract void setProperties(BuildInfoProperties... properties)

Set the BuildInfoProperties for the IBuildInfo instance.

abstract void setTestTag(String testTag)

Sets the unique name for the tests being run.

default File stageRemoteFile(String fileName, File workingDir)

Stage a file that's part of remote files in the build info's root dir.

default BuildInformation.BuildInfo toProto()

Serialize a the BuildInfo instance into a protobuf.

Constants

REMOTE_FILE_PREFIX

public static final String REMOTE_FILE_PREFIX

Prefix used in name to indicate the file is set to be delayed download.

Constant Value: "remote_file:"

REMOTE_FILE_VERSION

public static final String REMOTE_FILE_VERSION

Remote file is not versioned.

Constant Value: ""

UNKNOWN_BUILD_ID

public static final String UNKNOWN_BUILD_ID

Default value when build ID is unknown.

Constant Value: "-1"

Public methods

addAppPackageFile

public void addAppPackageFile (File appPackageFile, 
                String version)

Adds the local apk file and its associated version. Note that apks will be returned from getAppPackageFiles() in the order in which they were added by this method.

Parameters
appPackageFile File

version String

addBuildAttribute

public abstract void addBuildAttribute (String attributeName, 
                String attributeValue)

Add a build attribute. This doesn't allow overriding an existing attributeName.

Parameters
attributeName String: the unique attribute name

attributeValue String: the attribute value

addBuildAttributes

public void addBuildAttributes ( buildAttributes)

Add build attributes

Parameters
buildAttributes : Map of attributes to be added

allowStagingRemoteFile

public void allowStagingRemoteFile (boolean stageRemoteFile)

Sets permission to allow staging remote files.

Parameters
stageRemoteFile boolean

cleanUp

public abstract void cleanUp ()

Clean up any temporary build files

cleanUp

public abstract void cleanUp ( doNotDelete)

Version of cleanUp() where some files are not deleted.

Parameters
doNotDelete

clone

public abstract IBuildInfo clone ()

Clones the IBuildInfo object.

Returns
IBuildInfo

getAppPackageFiles

public  getAppPackageFiles ()

Gets a copy of the set of local app apk file(s) and their versions. The returned order matches the order in which the apks were added to the IAppBuildInfo.

Returns

getBuildAttributes

public abstract  getBuildAttributes ()

Get a set of name-value pairs of additional attributes describing the build.

Returns
a ERROR(/Map) of build attributes. Will not be null, but may be empty.

getBuildBranch

public abstract String getBuildBranch ()

Optional method to return the source control branch that the build being tested was produced from.

Returns
String the build branch or null if unset/not applicable

getBuildFlavor

public abstract String getBuildFlavor ()

Optional method to return the type of build being tested.

A common implementation for Android platform builds is to return (build product)-(build os)-(build variant). ie generic-linux-userdebug

Returns
String the build flavor or null if unset/not applicable

getBuildId

public abstract String getBuildId ()

Returns the unique identifier of build under test. Should never be null. Defaults to UNKNOWN_BUILD_ID.

Returns
String

getBuildTargetName

public abstract String getBuildTargetName ()

Return complete name for the build being tested.

A common implementation is to construct the build target name from a combination of the build flavor and branch name. [ie (branch name)-(build flavor)]

Returns
String

getDeviceSerial

public abstract String getDeviceSerial ()

Returns
String the ITestDevice serial that this build was executed on. Returns null if no device is associated with this build.

getFile

public abstract File getFile (String name)

Helper method to retrieve a file with given name.

Returns
File the image file or null if not found

getFile

public File getFile (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file with given a BuildInfoFileKey.

Parameters
key BuildInfoKey.BuildInfoFileKey: the BuildInfoFileKey that is requested.

Returns
File the image file or null if not found

getFiles

public abstract  getFiles ()

Returns all VersionedFiles stored in this BuildInfo.

Returns

getProperties

public abstract  getProperties ()

Returns a copy of the properties currently set on the IBuildInfo.

Returns

getRemoteFiles

public  getRemoteFiles ()

Get the paths for build artifacts that are delayed download.

Returns

getTestTag

public abstract String getTestTag ()

Return a unique name for the tests being run.

Returns
String

getVersion

public String getVersion (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file version with given a BuildInfoFileKey.

Parameters
key BuildInfoKey.BuildInfoFileKey: The BuildInfoFileKey requested.

Returns
String the image version or null if not found

getVersion

public abstract String getVersion (String name)

Helper method to retrieve a file version with given name.

Returns
String the image version or null if not found

getVersionedFile

public VersionedFile getVersionedFile (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a VersionedFile with a given BuildInfoFileKey.

Parameters
key BuildInfoKey.BuildInfoFileKey: The BuildInfoFileKey requested.

Returns
VersionedFile The versioned file or null if not found

getVersionedFile

public VersionedFile getVersionedFile (String name)

Helper method to retrieve a VersionedFile with a given name.

Returns
VersionedFile The versioned file or null if not found

getVersionedFileKeys

public  getVersionedFileKeys ()

Returns the set of keys available to query VersionedFile via getFile(BuildInfoFileKey).

Returns

getVersionedFiles

public  getVersionedFiles (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a list of VersionedFiles associated with a given BuildInfoFileKey. If the key allows to store a list.

Parameters
key BuildInfoKey.BuildInfoFileKey: The BuildInfoFileKey requested.

Returns
The versioned file or null if not found

removeBuildAttribute

public void removeBuildAttribute (String attributeName)

Remove a given attributeName from tracking.

Parameters
attributeName String: the attribute to stop tracking

setBuildBranch

public abstract void setBuildBranch (String branch)

Set the build branch

Parameters
branch String: the branch name

setBuildFlavor

public abstract void setBuildFlavor (String buildFlavor)

Set the build flavor.

setBuildId

public abstract void setBuildId (String buildId)

Sets the unique identifier of build under test. Should never be null.

Parameters
buildId String

setDeviceSerial

public abstract void setDeviceSerial (String serial)

Set the ITestDevice serial associated with this build.

Parameters
serial String: the serial number of the ITestDevice that this build was executed with.

setFile

public abstract void setFile (String name, 
                File file, 
                String version)

Stores an file with given name in this build info.

Parameters
name String: the unique name of the file

file File: the local ERROR(/File)

version String: the file version

setFile

public void setFile (BuildInfoKey.BuildInfoFileKey key, 
                File file, 
                String version)

Stores an file given a BuildInfoFileKey in this build info.

Parameters
key BuildInfoKey.BuildInfoFileKey: the unique name of the file based on BuildInfoFileKey.

file File: the local ERROR(/File)

version String: the file version

setProperties

public abstract void setProperties (BuildInfoProperties... properties)

Set the BuildInfoProperties for the IBuildInfo instance. Override any existing properties set before.

Parameters
properties BuildInfoProperties: The list of properties to add.

setTestTag

public abstract void setTestTag (String testTag)

Sets the unique name for the tests being run.

Parameters
testTag String

stageRemoteFile

public File stageRemoteFile (String fileName, 
                File workingDir)

Stage a file that's part of remote files in the build info's root dir.

TODO(b/138416078): Remove this interface and its caller when modules required by a test can be properly built output to the test module's directory itself.

Parameters
fileName String: Name of the file to be located in remote files.

workingDir File: a ERROR(/File) object of the directory to stage the file.

Returns
File the ERROR(/File) object of the file staged in local workingDir.

toProto

public BuildInformation.BuildInfo toProto ()

Serialize a the BuildInfo instance into a protobuf.

Returns
BuildInformation.BuildInfo