Skip to content

Commit

Permalink
[JENKINS-22637] [JENKINS-26810] Handle file modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Feb 21, 2018
1 parent b3e6d53 commit e617d81
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
14 changes: 9 additions & 5 deletions pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.37</version>
<version>3.4</version>
<relativePath />
</parent>

Expand All @@ -24,9 +24,9 @@
</licenses>

<properties>
<!-- To support (and test) @Symbol annotations (requires workflow-cps >= 2.10) -->
<jenkins.version>1.642.3</jenkins.version>
<java.level>7</java.level>
<jenkins-core.version>2.109-20180221.170307-1</jenkins-core.version> <!-- TODO https://github.com/jenkinsci/jenkins/pull/3302 -->
<jenkins-war.version>2.109-20180221.170329-1</jenkins-war.version>
<java.level>8</java.level>
</properties>

<dependencies>
Expand All @@ -35,7 +35,7 @@
<artifactId>maven-plugin</artifactId>
<version>2.7.1</version>
<optional>true</optional>
<exclusions>
<exclusions> <!-- TODO use 3.0 -->
<!-- See https://issues.jenkins-ci.org/browse/JENKINS-25625 -->
<exclusion>
<groupId>org.jenkins-ci</groupId>
Expand All @@ -57,6 +57,10 @@
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
Expand Up @@ -601,7 +601,7 @@ private static String normalizePattern(String p) {

private static void copyOne(Run<?,?> src, Run<?,?> dst, Map<String, String> fingerprints, VirtualFile s, FilePath d, MessageDigest md5) throws IOException, InterruptedException {
assert (fingerprints == null) == (md5 == null);
// TODO JENKINS-26810 handle symlinks and file attributes if supported
// TODO JENKINS-26810 handle symlinks
try {
try (InputStream is = s.open(); OutputStream os = d.write()) {
OutputStream os2;
Expand All @@ -619,6 +619,10 @@ private static void copyOne(Run<?,?> src, Run<?,?> dst, Map<String, String> fing
} catch (IOException x) {
LOGGER.warning(x.getMessage());
}
int mode = s.mode();
if (mode != -1) {
d.chmod(mode);
}
if (fingerprints != null) {
String digest = Util.toHexString(md5.digest());
FingerprintMap map = Jenkins.getActiveInstance().getFingerprintMap();
Expand Down
Expand Up @@ -102,7 +102,7 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
}
}
for (StringParameterValue spv : filters) {
if (!spv.value.equals(otherEnv.get(spv.getName()))) {
if (!spv.getValue().equals(otherEnv.get(spv.getName()))) {
return false;
}
}
Expand Down
16 changes: 3 additions & 13 deletions src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
Expand Up @@ -65,7 +65,6 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import jenkins.model.Jenkins;
import jenkins.security.QueueItemAuthenticatorConfiguration;
Expand Down Expand Up @@ -94,11 +93,13 @@
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.google.common.collect.Sets;
import jenkins.model.ArtifactManagerConfiguration;
import static org.hamcrest.Matchers.*;
import org.jenkinsci.plugins.compress_artifacts.CompressingArtifactManagerFactory;

import org.jvnet.hudson.test.TestBuilder;

import static org.junit.Assert.*;
import static org.junit.Assume.*;
import org.junit.Ignore;

/**
Expand Down Expand Up @@ -1671,20 +1672,9 @@ public void testWebConfiguration() throws Exception {
}
}

private boolean isFilePermissionSupported() throws Exception {
return rule.jenkins.getRootPath().mode() != -1;
}

@Ignore("TODO not yet (re-)implemented")
@Test
public void testFilePermission() throws Exception {
if (!isFilePermissionSupported()) {
Logger.getLogger(CopyArtifactTest.class.getName()).warning(String.format(
"Skipped %s as file permission is not supported on this platform",
name.getMethodName()
));
return;
}
assumeThat(rule.jenkins.getRootPath().mode(), not(-1));

FreeStyleProject copiee = rule.createFreeStyleProject();
FreeStyleBuild copieeBuild = copiee.scheduleBuild2(0).get();
Expand Down

0 comments on commit e617d81

Please sign in to comment.