Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-32328] handling tool Installers which do not have the defaul…
…t schema
- Loading branch information
Showing
5 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,13 +136,39 @@ public Downloadable createDownloadable() { | |
final DownloadFromUrlInstaller.DescriptorImpl delegate = (DownloadFromUrlInstaller.DescriptorImpl)this; | ||
return new Downloadable(getId()) { | ||
public JSONObject reduce(List<JSONObject> jsonList) { | ||
return delegate.reduce(jsonList); | ||
if (isDefualtSchema(jsonList)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
varmenise
Author
Contributor
|
||
return delegate.reduce(jsonList); | ||
} else { | ||
//if it's not default schema fall back to the super class implementation | ||
return super.reduce(jsonList); | ||
} | ||
} | ||
}; | ||
} | ||
return new Downloadable(getId()); | ||
} | ||
|
||
/** | ||
* this function checks is the update center tool has the default schema | ||
* @param jsonList the list of Update centers json files | ||
* @return true if the schema is the default one (id, name, url), false otherwise | ||
*/ | ||
private boolean isDefualtSchema(List<JSONObject> jsonList) { | ||
JSONObject jsonToolInstallerList = jsonList.get(0); | ||
ToolInstallerList toolInstallerList = (ToolInstallerList) JSONObject.toBean(jsonToolInstallerList, ToolInstallerList.class); | ||
|
||
if (toolInstallerList != null) { | ||
ToolInstallerEntry[] entryList = toolInstallerList.list; | ||
ToolInstallerEntry sampleEntry = entryList[0]; | ||
if (sampleEntry != null) { | ||
if (sampleEntry.id != null && sampleEntry.name != null && sampleEntry.url != null) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private JSONObject reduce(List<JSONObject> jsonList) { | ||
List<ToolInstallerEntry> reducedToolEntries = new LinkedList<>(); | ||
//collect all tool installers objects from the multiple json objects | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstaller1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
downloadService.post('hudson.plugins.cmake.CmakeInstaller',{"list": [ | ||
{ | ||
"id": "3.4.2", | ||
"name": "3.4.2", | ||
"variants": [ | ||
{ | ||
"arch": "x86", | ||
"os": "win32", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-win32-x86.zip" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-Linux-x86_64.tar.gz" | ||
}, | ||
{ | ||
"arch": "i386", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-Linux-i386.tar.gz" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Darwin", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-Darwin-x86_64.tar.gz" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "3.4.1", | ||
"name": "3.4.1", | ||
"variants": [ | ||
{ | ||
"arch": "x86", | ||
"os": "win32", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-win32-x86.zip" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-Linux-x86_64.tar.gz" | ||
}, | ||
{ | ||
"arch": "i386", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-Linux-i386.tar.gz" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Darwin", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-Darwin-x86_64.tar.gz" | ||
} | ||
] | ||
} | ||
]}) |
48 changes: 48 additions & 0 deletions
48
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstaller2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
downloadService.post('hudson.plugins.cmake.CmakeInstaller',{"list": [ | ||
{ | ||
"id": "2.6.1", | ||
"name": "2.6.1", | ||
"variants": [ | ||
{ | ||
"arch": "x86", | ||
"os": "win32", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-win32-x86.zip" | ||
}, | ||
{ | ||
"arch": "sparc", | ||
"os": "SunOS", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-SunOS-sparc.tar.gz" | ||
}, | ||
{ | ||
"arch": "i386", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-Linux-i386.tar.gz" | ||
}, | ||
{ | ||
"arch": "n32", | ||
"os": "IRIX64", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-IRIX64-n32.tar.gz" | ||
}, | ||
{ | ||
"arch": "64", | ||
"os": "IRIX64", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-IRIX64-64.tar.gz" | ||
}, | ||
{ | ||
"arch": "9000_785", | ||
"os": "HP-UX", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-HP-UX-9000_785.tar.gz" | ||
}, | ||
{ | ||
"arch": "universal", | ||
"os": "Darwin", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-Darwin-universal.tar.gz" | ||
}, | ||
{ | ||
"arch": "powerpc", | ||
"os": "AIX", | ||
"url": "https://cmake.org/files/v2.6/cmake-2.6.1-AIX-powerpc.tar.gz" | ||
} | ||
] | ||
} | ||
]}) |
54 changes: 54 additions & 0 deletions
54
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstallerResult.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
downloadService.post('hudson.plugins.cmake.CmakeInstaller',{"list": [ | ||
{ | ||
"id": "3.4.2", | ||
"name": "3.4.2", | ||
"variants": [ | ||
{ | ||
"arch": "x86", | ||
"os": "win32", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-win32-x86.zip" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-Linux-x86_64.tar.gz" | ||
}, | ||
{ | ||
"arch": "i386", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-Linux-i386.tar.gz" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Darwin", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.2-Darwin-x86_64.tar.gz" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "3.4.1", | ||
"name": "3.4.1", | ||
"variants": [ | ||
{ | ||
"arch": "x86", | ||
"os": "win32", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-win32-x86.zip" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-Linux-x86_64.tar.gz" | ||
}, | ||
{ | ||
"arch": "i386", | ||
"os": "Linux", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-Linux-i386.tar.gz" | ||
}, | ||
{ | ||
"arch": "x86_64", | ||
"os": "Darwin", | ||
"url": "https://cmake.org/files/v3.4/cmake-3.4.1-Darwin-x86_64.tar.gz" | ||
} | ||
] | ||
} | ||
]}) |
1 comment
on commit e7f8814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps some typos isDefualtSchema instead of isDefaultSchema?
isDefualtSchema or isDefaultSchema? Appears to be a typo.