Skip to content

Commit

Permalink
Resolve container name on load (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Nov 2, 2022
1 parent 7989b9c commit af4232a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
15 changes: 7 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.18</version>
<version>4.49</version>
<relativePath/>
</parent>
<artifactId>azure-artifact-manager</artifactId>
Expand All @@ -16,8 +16,7 @@

<properties>
<changelist>9999-SNAPSHOT</changelist>
<jenkins.version>2.277.2</jenkins.version>
<java.level>8</java.level>
<jenkins.version>2.346.3</jenkins.version>
</properties>

<licenses>
Expand All @@ -43,8 +42,8 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.277.x</artifactId>
<version>909.vf028101f1bfa</version>
<artifactId>bom-2.346.x</artifactId>
<version>1654.vcb_69d035fa_20</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -55,7 +54,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>windows-azure-storage</artifactId>
<version>359.v09573e5ff73f</version>
<version>380.va3a027b784f4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand All @@ -70,7 +69,7 @@
<dependency>
<groupId>org.jenkins-ci.test</groupId>
<artifactId>docker-fixtures</artifactId>
<version>1.11</version>
<version>166.v912b_95083ffe</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -117,7 +116,7 @@

<url>https://github.com/jenkinsci/azure-artifact-manager-plugin</url>
<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<connection>scm:git:https://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>${scmTag}</tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
@Restricted(NoExternalUse.class)
public final class AzureArtifactManager extends ArtifactManager implements StashManager.StashAwareArtifactManager {
private static final Logger LOGGER = Logger.getLogger(ArtifactManager.class.getName());
private final Run<?, ?> build;
private transient Run<?, ?> build;
private final AzureArtifactConfig config;
private String actualContainerName;

Expand All @@ -89,7 +89,6 @@ public AzureArtifactManager(Run<?, ?> build, AzureArtifactConfig config) {
String prefix = config.getPrefix();
checkConfig(containerName, prefix);

this.build = build;
this.config = config;
onLoad(build);
}
Expand All @@ -108,8 +107,19 @@ private void checkConfig(String containerName, String prefix) {

@Override
public void onLoad(Run<?, ?> aBuild) {
this.build = aBuild;
this.defaultKey = String.format(Constants.BUILD_PREFIX_FORMAT, aBuild.getParent().getFullName(),
aBuild.getNumber()).replace("%2F", "/");

if (this.actualContainerName == null) {
try {
EnvVars envVars = build.getEnvironment(new LogTaskListener(LOGGER, Level.INFO));
this.actualContainerName = Utils
.replaceMacro(Util.fixNull(config.getContainer()), envVars, Locale.ENGLISH);
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -107,7 +106,6 @@ public <V> V run(Callable<V, IOException> callable) throws IOException {
Map<String, CachedMetadata> saved = new HashMap<>();
try {
StorageAccountInfo accountInfo = Utils.getStorageAccount(build.getParent());
Objects.requireNonNull(this.container, "Container must not be null");
BlobContainerClient blobContainerReference = Utils.getBlobContainerReference(accountInfo, this.container,
false);
ListBlobsOptions listBlobsOptions = new ListBlobsOptions()
Expand Down

0 comments on commit af4232a

Please sign in to comment.