Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
caf3e080
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
caf3e080
编写于
7月 19, 2018
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-52665] Treat plugin dependency mismatches involving snapshots as nonfatal.
上级
d71ac6ff
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
10 deletion
+38
-10
core/src/main/java/hudson/PluginWrapper.java
core/src/main/java/hudson/PluginWrapper.java
+24
-7
core/src/test/java/hudson/PluginWrapperTest.java
core/src/test/java/hudson/PluginWrapperTest.java
+14
-3
未找到文件。
core/src/main/java/hudson/PluginWrapper.java
浏览文件 @
caf3e080
...
...
@@ -36,7 +36,6 @@ import jenkins.model.Jenkins;
import
hudson.model.UpdateCenter
;
import
hudson.model.UpdateSite
;
import
hudson.util.VersionNumber
;
import
org.jvnet.localizer.ResourceBundleHolder
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.DoNotUse
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
...
...
@@ -54,7 +53,6 @@ import javax.annotation.CheckForNull;
import
javax.annotation.Nonnull
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.URL
;
...
...
@@ -64,7 +62,6 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -600,7 +597,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
}
else
{
VersionNumber
actualVersion
=
Jenkins
.
getVersion
();
if
(
actualVersion
.
isOlderThan
(
new
VersionNumber
(
requiredCoreVersion
)))
{
dependencyErrors
.
put
(
Messages
.
PluginWrapper_obsoleteCore
(
Jenkins
.
getVersion
().
toString
(),
requiredCoreVersion
),
false
);
versionDependencyError
(
Messages
.
PluginWrapper_obsoleteCore
(
Jenkins
.
getVersion
().
toString
(),
requiredCoreVersion
),
Jenkins
.
getVersion
().
toString
(),
requiredCoreVersion
);
}
}
}
...
...
@@ -618,11 +615,11 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
}
else
{
if
(
dependency
.
isActive
())
{
if
(
isDependencyObsolete
(
d
,
dependency
))
{
dependencyErrors
.
put
(
Messages
.
PluginWrapper_obsolete
(
dependency
.
getLongName
(),
dependency
.
getVersion
(),
d
.
version
),
false
);
versionDependencyError
(
Messages
.
PluginWrapper_obsolete
(
dependency
.
getLongName
(),
dependency
.
getVersion
(),
d
.
version
),
dependency
.
getVersion
(),
d
.
version
);
}
}
else
{
if
(
isDependencyObsolete
(
d
,
dependency
))
{
dependencyErrors
.
put
(
Messages
.
PluginWrapper_disabledAndObsolete
(
dependency
.
getLongName
(),
dependency
.
getVersion
(),
d
.
version
),
false
);
versionDependencyError
(
Messages
.
PluginWrapper_disabledAndObsolete
(
dependency
.
getLongName
(),
dependency
.
getVersion
(),
d
.
version
),
dependency
.
getVersion
(),
d
.
version
);
}
else
{
dependencyErrors
.
put
(
Messages
.
PluginWrapper_disabled
(
dependency
.
getLongName
()),
false
);
}
...
...
@@ -635,7 +632,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
PluginWrapper
dependency
=
parent
.
getPlugin
(
d
.
shortName
);
if
(
dependency
!=
null
&&
dependency
.
isActive
())
{
if
(
isDependencyObsolete
(
d
,
dependency
))
{
dependencyErrors
.
put
(
Messages
.
PluginWrapper_obsolete
(
dependency
.
getLongName
(),
dependency
.
getVersion
(),
d
.
version
),
false
);
versionDependencyError
(
Messages
.
PluginWrapper_obsolete
(
dependency
.
getLongName
(),
dependency
.
getVersion
(),
d
.
version
),
dependency
.
getVersion
(),
d
.
version
);
}
else
{
dependencies
.
add
(
d
);
}
...
...
@@ -660,6 +657,26 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
return
ENABLE_PLUGIN_DEPENDENCIES_VERSION_CHECK
&&
dependency
.
getVersionNumber
().
isOlderThan
(
new
VersionNumber
(
d
.
version
));
}
/**
* Called when there appears to be a core or plugin version which is too old for a stated dependency.
* Normally records an error in {@link #dependencyErrors}.
* But if one or both versions {@link #isSnapshot}, just issue a warning (JENKINS-52665).
*/
private
void
versionDependencyError
(
String
message
,
String
actual
,
String
minimum
)
{
if
(
isSnapshot
(
actual
)
||
isSnapshot
(
minimum
))
{
LOGGER
.
log
(
WARNING
,
"Suppressing dependency error in {0} v{1}: {2}"
,
new
Object
[]
{
getLongName
(),
getVersion
(),
message
});
}
else
{
dependencyErrors
.
put
(
message
,
false
);
}
}
/**
* Similar to {@code org.apache.maven.artifact.ArtifactUtils.isSnapshot}.
*/
static
boolean
isSnapshot
(
@Nonnull
String
version
)
{
return
version
.
contains
(
"-SNAPSHOT"
)
||
version
.
matches
(
".+-[0-9]{8}.[0-9]{6}-[0-9]+"
);
}
/**
* If the plugin has {@link #getUpdateInfo() an update},
* returns the {@link hudson.model.UpdateSite.Plugin} object.
...
...
core/src/test/java/hudson/PluginWrapperTest.java
浏览文件 @
caf3e080
...
...
@@ -15,9 +15,8 @@ import org.mockito.invocation.InvocationOnMock;
import
org.mockito.stubbing.Answer
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
junit
.
Assert
.*;
import
org.jvnet.hudson.test.Issue
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
@@ -180,4 +179,16 @@ public class PluginWrapperTest {
);
}
}
@Issue
(
"JENKINS-52665"
)
@Test
public
void
isSnapshot
()
{
assertFalse
(
PluginWrapper
.
isSnapshot
(
"1.0"
));
assertFalse
(
PluginWrapper
.
isSnapshot
(
"1.0-alpha-1"
));
assertFalse
(
PluginWrapper
.
isSnapshot
(
"1.0-rc9999.abc123def456"
));
assertTrue
(
PluginWrapper
.
isSnapshot
(
"1.0-SNAPSHOT"
));
assertTrue
(
PluginWrapper
.
isSnapshot
(
"1.0-20180719.153600-1"
));
assertTrue
(
PluginWrapper
.
isSnapshot
(
"1.0-SNAPSHOT (private-abcd1234-jqhacker)"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录