jenkinsci / jenkinsci/git-plugin
[JENKINS-38800] remoteUrls are unordered in build data JSON when multiple git repositories are configured
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
When multiple Git repositories are added to the git plugin (not Multiple SCM plugin), the remoteUrls in the build data JSON are unordered (different from the order in which they were configured in the Jenkins job). This is because the remoteUrls are stored in a HashSet in BuildData.java. We can instead store them in a LinkedHashSet and preserve the order.
This is needed so that we can associate the branch built, origin[x] (where x is the repository index) in lastBuiltRevision with the appropriate repository URL for which there is no provision right now when there are multiple repositories.
{
"buildsByBranchName" : {
"origin/master" : {
"buildNumber" : 1813,
"buildResult" : null,
"revision" :
{
"SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6",
"branch" : [
{ "SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6", "name" : "origin/master" }
]
}
},
"origin/mri" : {
"buildNumber" : 50,
"buildResult" : null,
"revision" :
{
"SHA1" : "f68f612f42908af792e831613deb4b6fe43ff513",
"branch" : [
{ "SHA1" : "f68f612f42908af792e831613deb4b6fe43ff513", "name" : "origin/mri" }
]
}
}
},
"lastBuiltRevision" :
{
"SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6",
"branch" : [
{ "SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6", "name" : "origin1/master" }
],
"remoteUrls" : [
"https://github.com/repo1.git",
"https://github.com/repo2.git",
]
}
---
Originally reported by pxk5958, imported from: remoteUrls are unordered in build data JSON when multiple git repositories are configured
Raw content of original issue
When multiple Git repositories are added to the git plugin (not Multiple SCM plugin), the remoteUrls in the build data JSON are unordered (different from the order in which they were configured in the Jenkins job). This is because the remoteUrls are stored in a HashSet in BuildData.java. We can instead store them in a LinkedHashSet and preserve the order.
This is needed so that we can associate the branch built, origin[x] (where x is the repository index) in lastBuiltRevision with the appropriate repository URL for which there is no provision right now when there are multiple repositories.
{
"buildsByBranchName" : {
"origin/master" : {
"buildNumber" : 1813,
"buildResult" : null,
"revision" :
{
"SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6",
"branch" : [
{ "SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6", "name" : "origin/master" }]
}
},
"origin/mri" : {
"buildNumber" : 50,
"buildResult" : null,
"revision" :
{
"SHA1" : "f68f612f42908af792e831613deb4b6fe43ff513",
"branch" : [
{ "SHA1" : "f68f612f42908af792e831613deb4b6fe43ff513", "name" : "origin/mri" }]
}
}
},
"lastBuiltRevision" :
{
"SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6",
"branch" : [
{ "SHA1" : "a0b422c02d45c71ca6e5317eb3aa6026d0f4ada6", "name" : "origin1/master" }],
"remoteUrls" : [
"https://github.com/repo1.git",
"https://github.com/repo2.git",
]
}
environment
```
Operating System:
Jenkins server running on Windows 7 Enterprise SP1 (64-bit), slave node running on Ubuntu 3.13.0-85-generic (64-bit) VM launched via SSH.
Java 1.8
Jenkins ver. 2.7.1, Git plugin ver. 3.0.0
Browser: Google Chrome Version 53.0.2785.116 m (64-bit)
```
Contributor guide
Assessment
This issue has not been assessed yet.