Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
e7f88146
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e7f88146
编写于
1月 22, 2016
作者:
V
Valentina Armenise
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-32328] handling tool Installers which do not have the default schema
上级
80a6a9e7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
217 addition
and
1 deletion
+217
-1
core/src/main/java/hudson/tools/DownloadFromUrlInstaller.java
.../src/main/java/hudson/tools/DownloadFromUrlInstaller.java
+27
-1
test/src/test/java/hudson/model/DownloadServiceTest.java
test/src/test/java/hudson/model/DownloadServiceTest.java
+34
-0
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstaller1.json
...es/hudson/model/hudson.plugins.cmake.CmakeInstaller1.json
+54
-0
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstaller2.json
...es/hudson/model/hudson.plugins.cmake.CmakeInstaller2.json
+48
-0
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstallerResult.json
...dson/model/hudson.plugins.cmake.CmakeInstallerResult.json
+54
-0
未找到文件。
core/src/main/java/hudson/tools/DownloadFromUrlInstaller.java
浏览文件 @
e7f88146
...
...
@@ -136,13 +136,39 @@ public abstract class DownloadFromUrlInstaller extends ToolInstaller {
final
DownloadFromUrlInstaller
.
DescriptorImpl
delegate
=
(
DownloadFromUrlInstaller
.
DescriptorImpl
)
this
;
return
new
Downloadable
(
getId
())
{
public
JSONObject
reduce
(
List
<
JSONObject
>
jsonList
)
{
return
delegate
.
reduce
(
jsonList
);
if
(
isDefualtSchema
(
jsonList
))
{
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
...
...
test/src/test/java/hudson/model/DownloadServiceTest.java
浏览文件 @
e7f88146
...
...
@@ -9,7 +9,9 @@ import java.util.Set;
import
java.util.TreeSet
;
import
hudson.tasks.Maven
;
import
hudson.tools.DownloadFromUrlInstaller
;
import
hudson.tools.JDKInstaller
;
import
hudson.tools.ToolInstallation
;
import
jenkins.model.DownloadSettings
;
import
net.sf.json.JSONObject
;
import
org.jvnet.hudson.test.Issue
;
...
...
@@ -127,4 +129,36 @@ public class DownloadServiceTest extends HudsonTestCase {
JSONObject
expectedResultJson
=
JSONObject
.
fromObject
(
DownloadService
.
loadJSON
(
expectedResult
));
assertEquals
(
reducedJson
,
expectedResultJson
);
}
public
void
testReduceFunctionWithNotDefaultSchemaJsons
()
throws
Exception
{
URL
resource1
=
DownloadServiceTest
.
class
.
getResource
(
"hudson.plugins.cmake.CmakeInstaller1.json"
);
URL
resource2
=
DownloadServiceTest
.
class
.
getResource
(
"hudson.plugins.cmake.CmakeInstaller2.json"
);
JSONObject
json1
=
JSONObject
.
fromObject
(
DownloadService
.
loadJSON
(
resource1
));
JSONObject
json2
=
JSONObject
.
fromObject
(
DownloadService
.
loadJSON
(
resource2
));
List
<
JSONObject
>
jsonObjectList
=
new
ArrayList
<>();
jsonObjectList
.
add
(
json1
);
jsonObjectList
.
add
(
json2
);
Downloadable
downloadable
=
new
GenericDownloadFromUrlInstaller
.
DescriptorImpl
().
createDownloadable
();
JSONObject
reducedJson
=
downloadable
.
reduce
(
jsonObjectList
);
URL
expectedResult
=
DownloadServiceTest
.
class
.
getResource
(
"hudson.plugins.cmake.CmakeInstallerResult.json"
);
JSONObject
expectedResultJson
=
JSONObject
.
fromObject
(
DownloadService
.
loadJSON
(
expectedResult
));
assertEquals
(
reducedJson
,
expectedResultJson
);
}
private
static
class
GenericDownloadFromUrlInstaller
extends
DownloadFromUrlInstaller
{
protected
GenericDownloadFromUrlInstaller
(
String
id
)
{
super
(
id
);
}
public
static
final
class
DescriptorImpl
extends
DownloadFromUrlInstaller
.
DescriptorImpl
<
Maven
.
MavenInstaller
>
{
public
String
getDisplayName
()
{
return
""
;
}
@Override
public
boolean
isApplicable
(
Class
<?
extends
ToolInstallation
>
toolType
)
{
return
true
;
}
}
}
}
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstaller1.json
0 → 100644
浏览文件 @
e7f88146
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"
}
]
}
]}
)
\ No newline at end of file
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstaller2.json
0 → 100644
浏览文件 @
e7f88146
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"
}
]
}
]}
)
\ No newline at end of file
test/src/test/resources/hudson/model/hudson.plugins.cmake.CmakeInstallerResult.json
0 → 100644
浏览文件 @
e7f88146
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"
}
]
}
]}
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录