Skip to content

[JENKINS-75208] Checkout on bitbucket server fail with IllegalArgumentException "Name cannot contain '/'" #981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ public SCMFile getFile(@NonNull BitbucketSCMFile file) throws IOException, Inter
} catch (FileNotFoundException e) {
type = Type.NONEXISTENT;
}
return new BitbucketSCMFile((BitbucketSCMFile) file.parent(), file.getRef(), type, file.getHash());
return new BitbucketSCMFile((BitbucketSCMFile) file.parent(), file.getName(), type, file.getHash());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

@WithJenkins
class BitbucketSCMFileTest {
Expand All @@ -53,11 +54,29 @@ static void init(JenkinsRule rule) {
void verify_content_throws_FileNotFoundException_when_file_does_not_exists() {
BitbucketApi client = BitbucketIntegrationClientFactory.getApiMockClient("https://acme.bitbucket.com");

BitbucketSCMFile parent = new BitbucketSCMFile(client, "master", "hash");
BitbucketSCMFile parent = new BitbucketSCMFile(client, "master", "51af66dad14c38d7c69874c57a65f77f688e3f33");
BitbucketSCMFile file = new BitbucketSCMFile(parent, "pipeline_config.groovy", Type.REGULAR_FILE, "046d9a3c1532acf4cf08fe93235c00e4d673c1d2");
assertThatThrownBy(file::content).isInstanceOf(FileNotFoundException.class);
}

@Issue("JENKINS-75208")
@Test
void test_SCMFile_does_not_contains_illegal_chars_in_the_name() throws Exception {
BitbucketApi client = BitbucketIntegrationClientFactory.getApiMockClient("https://acme.bitbucket.com");

BitbucketSCMFile parent = new BitbucketSCMFile(client, "feature/pipeline", null);
BitbucketSCMFile file = new BitbucketSCMFile(parent, "Jenkinsfile", null, "2c130d767a38ac4ef511797f221315f35a2aea55");
SCMFile scmFile = assertDoesNotThrow(() -> client.getFile(file));

assertThat(scmFile.isFile()).isTrue();
assertThat(scmFile.getName()).isEqualTo("Jenkinsfile");
assertThat(scmFile).isInstanceOfSatisfying(BitbucketSCMFile.class,
f -> {
assertThat(f.getRef()).isEqualTo("feature/pipeline");
assertThat(f.getHash()).isEqualTo("2c130d767a38ac4ef511797f221315f35a2aea55");
});
}

@Issue("JENKINS-75157")
@Test
void test_SCMBinder_behavior_when_discover_the_Jenkinsfile_for_a_given_branch_on_cloud() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "FILE"
}
Loading