From 54f125b3e1c7154bdd222b6b85092cbf6447a299 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 28 May 2024 18:37:52 -0400 Subject: [PATCH] Set `safe.directory` in `WithMavenStepTest.tesWithDifferentJavasForBuild` (#796) --- .../plugins/pipeline/maven/WithMavenStepTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepTest.java b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepTest.java index 870942ca..71b88559 100644 --- a/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepTest.java +++ b/pipeline-maven/src/test/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepTest.java @@ -58,6 +58,8 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.jvnet.hudson.test.Issue; +import org.testcontainers.containers.ExecConfig; +import org.testcontainers.containers.ExecInContainerPattern; import org.testcontainers.containers.GenericContainer; import org.testcontainers.utility.MountableFile; @@ -142,6 +144,15 @@ public void tesWithDifferentJavasForBuild(String jdkName, String jdkPath) throws String gitRepoPath = this.gitRepoRule.toString(); javasContainerRule.copyFileToContainer(MountableFile.forHostPath(gitRepoPath), "/tmp/gitrepo"); javasContainerRule.execInContainer("chmod", "-R", "777", "/tmp/gitrepo"); + System.out.println(ExecInContainerPattern.execInContainer( + javasContainerRule.getDockerClient(), + javasContainerRule.getContainerInfo(), + ExecConfig.builder() + .user("test") + .command(new String[] { + "git", "config", "--global", "--add", "safe.directory", "/tmp/gitrepo/.git" + }) + .build())); registerAgentForContainer(javasContainerRule); ToolLocationNodeProperty.ToolLocation toolLocation = new ToolLocationNodeProperty.ToolLocation(new JDK.DescriptorImpl(), jdkName, jdkPath);