public class ArtifactPathBuilder extends Object
An artifact path can have two formats, a plan-oriented format and a global format. The plan-oriented format groups artifacts by the plans that produced them. The global format is independent of the plan. The global format may be used when an artifact needs to survive longer than the plan that created it.
The plan oriented format looks like this:
[artifact-root] / [chain-part] / [job-part] / [build-part] / [label-part]
Where [chain-part] is the chain key (eg. "PROJA-PLAN1"), [job-part] is either the partial job key (eg. "JOB14") or the value "shared" for shared artifacts, [build-part] is the build number prefixed with the string "build-" and [label-part] is a sanitised version of the artifact label specified by the user in the artifact definition.
Here are two examples of plan-oriented paths:
PROJA-PLAN1/JOB14/build-00035/my-non-shared-artifact PROJA-PLAN1/shared/build-00035/my-shared-artifact
The global format looks like this:
[artifact-root] / globalStorage / [artifact-id]
Where [artifact-id] is the plain database id of the artifact.
for example:
globalStorage/5898243
Constructor and Description |
---|
ArtifactPathBuilder(char separatorChar)
Constructor for building relative paths.
|
ArtifactPathBuilder(String rootStoragePath,
char separatorChar)
Constructor for building absolute paths.
|
Modifier and Type | Method and Description |
---|---|
String |
getArtifactPath(Artifact artifact)
Returns a plan-oriented or global storage path for the supplied artifact (based on the return value
of artifact.isGloballyStored().
|
String |
getBuildPath(PlanResultKey planResultKey)
Returns [artifact-root] / [chain-part] / [job-part] / [build-part]
[job-part] will be "shared" if the parameter points to a chain rather than a job.
|
String |
getChainPath(PlanKey planKey)
Returns [artifact-root] / [chain-part]
|
String |
getJobOrSharedPath(PlanKey planKey)
Returns [artifact-root] / [chain-part] / [job-part]
[job-part] will be "shared" if the parameter points to a chain rather than a job.
|
String |
getPlanOrientedArtifactPath(PlanResultKey planResultKey,
ImmutableArtifactDefinitionBase artifactDefinition)
Always returns a plan-oriented path, never a global storage path.
|
String |
getRootStoragePath()
Returns the root storage path that this instance is using to build absolute paths, or null if this instance is
configured to build relative paths.
|
String |
getTmpStoragePath() |
String |
normaliseArtifactPath(String relativeArtifactPath)
Normalises an artifact path by converting any non-standard elements into the standard form so that
the path can be used to find the artifact on disk (or other storage medium).
|
String |
substituteSymbolicBuildReference(String relativeArtifactPath,
Function<SymbolicBuildReference,Integer> function)
Substitutes the symbolic build reference "build-latest" or "build-latestSuccessful" in the specified artifact
path with the concrete build directory name associated with the appropriate build number.
|
public ArtifactPathBuilder(String rootStoragePath, char separatorChar)
public ArtifactPathBuilder(char separatorChar)
public String getRootStoragePath()
public String getTmpStoragePath()
public String getArtifactPath(Artifact artifact)
public String getPlanOrientedArtifactPath(PlanResultKey planResultKey, @Nullable ImmutableArtifactDefinitionBase artifactDefinition)
public String getJobOrSharedPath(PlanKey planKey)
public String getBuildPath(PlanResultKey planResultKey)
public String substituteSymbolicBuildReference(String relativeArtifactPath, Function<SymbolicBuildReference,Integer> function)
public String normaliseArtifactPath(String relativeArtifactPath)
Copyright © 2016 Atlassian Software Systems Pty Ltd. All rights reserved.