Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
729d41cf
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,发现更多精彩内容 >>
提交
729d41cf
编写于
11月 16, 2013
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-20609]
Implemented the hook
上级
6b8b266e
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
112 addition
and
53 deletion
+112
-53
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/WebAppMain.java
core/src/main/java/hudson/WebAppMain.java
+14
-22
core/src/main/java/hudson/util/AWTProblem.java
core/src/main/java/hudson/util/AWTProblem.java
+6
-1
core/src/main/java/hudson/util/BootFailure.java
core/src/main/java/hudson/util/BootFailure.java
+36
-0
core/src/main/java/hudson/util/ErrorObject.java
core/src/main/java/hudson/util/ErrorObject.java
+13
-1
core/src/main/java/hudson/util/HudsonFailedToLoad.java
core/src/main/java/hudson/util/HudsonFailedToLoad.java
+6
-7
core/src/main/java/hudson/util/IncompatibleAntVersionDetected.java
...main/java/hudson/util/IncompatibleAntVersionDetected.java
+10
-1
core/src/main/java/hudson/util/IncompatibleServletVersionDetected.java
.../java/hudson/util/IncompatibleServletVersionDetected.java
+1
-1
core/src/main/java/hudson/util/IncompatibleVMDetected.java
core/src/main/java/hudson/util/IncompatibleVMDetected.java
+1
-2
core/src/main/java/hudson/util/InsufficientPermissionDetected.java
...main/java/hudson/util/InsufficientPermissionDetected.java
+5
-6
core/src/main/java/hudson/util/JenkinsReloadFailed.java
core/src/main/java/hudson/util/JenkinsReloadFailed.java
+6
-1
core/src/main/java/hudson/util/NoHomeDir.java
core/src/main/java/hudson/util/NoHomeDir.java
+1
-1
core/src/main/java/hudson/util/NoTempDir.java
core/src/main/java/hudson/util/NoTempDir.java
+5
-5
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+1
-1
core/src/main/resources/hudson/util/HudsonFailedToLoad/index.jelly
...main/resources/hudson/util/HudsonFailedToLoad/index.jelly
+1
-1
core/src/main/resources/hudson/util/InsufficientPermissionDetected/index.jelly
...es/hudson/util/InsufficientPermissionDetected/index.jelly
+1
-1
core/src/main/resources/hudson/util/JNADoublyLoaded/index.jelly
...rc/main/resources/hudson/util/JNADoublyLoaded/index.jelly
+1
-1
core/src/main/resources/hudson/util/NoTempDir/index.jelly
core/src/main/resources/hudson/util/NoTempDir/index.jelly
+1
-1
未找到文件。
changelog.html
浏览文件 @
729d41cf
...
...
@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
rfe
>
Introduced the boot failure hook script that gets executed when Jenkins fails to start.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-20609"
>
issue 20609
</a>
)
<li
class=
bug
>
Fixed "java.lang.NoClassDefFoundError: JarURLConnection" on OpenJDK
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-20163"
>
issue 20163
</a>
)
...
...
core/src/main/java/hudson/WebAppMain.java
浏览文件 @
729d41cf
...
...
@@ -26,6 +26,7 @@ package hudson;
import
com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider
;
import
com.thoughtworks.xstream.core.JVM
;
import
hudson.model.Hudson
;
import
hudson.util.BootFailure
;
import
jenkins.model.Jenkins
;
import
hudson.util.HudsonIsLoading
;
import
hudson.util.IncompatibleServletVersionDetected
;
...
...
@@ -82,8 +83,8 @@ public final class WebAppMain implements ServletContextListener {
* Creates the sole instance of {@link jenkins.model.Jenkins} and register it to the {@link ServletContext}.
*/
public
void
contextInitialized
(
ServletContextEvent
event
)
{
final
ServletContext
context
=
event
.
getServletContext
();
try
{
final
ServletContext
context
=
event
.
getServletContext
();
// use the current request to determine the language
LocaleProvider
.
setProvider
(
new
LocaleProvider
()
{
...
...
@@ -98,8 +99,7 @@ public final class WebAppMain implements ServletContextListener {
jvm
=
new
JVM
();
new
URLClassLoader
(
new
URL
[
0
],
getClass
().
getClassLoader
());
}
catch
(
SecurityException
e
)
{
context
.
setAttribute
(
APP
,
new
InsufficientPermissionDetected
(
e
));
return
;
throw
new
InsufficientPermissionDetected
(
e
);
}
try
{
// remove Sun PKCS11 provider if present. See http://wiki.jenkins-ci.org/display/JENKINS/Solaris+Issue+6276483
...
...
@@ -116,16 +116,12 @@ public final class WebAppMain implements ServletContextListener {
System
.
out
.
println
(
"Jenkins home directory: "
+
home
+
" found at: "
+
describedHomeDir
.
description
);
// check that home exists (as mkdirs could have failed silently), otherwise throw a meaningful error
if
(!
home
.
exists
())
{
context
.
setAttribute
(
APP
,
new
NoHomeDir
(
home
));
return
;
}
if
(!
home
.
exists
())
throw
new
NoHomeDir
(
home
);
// make sure that we are using XStream in the "enhanced" (JVM-specific) mode
if
(
jvm
.
bestReflectionProvider
().
getClass
()==
PureJavaReflectionProvider
.
class
)
{
// nope
context
.
setAttribute
(
APP
,
new
IncompatibleVMDetected
());
return
;
throw
new
IncompatibleVMDetected
();
// nope
}
// JNA is no longer a hard requirement. It's just nice to have. See HUDSON-4820 for more context.
...
...
@@ -163,22 +159,19 @@ public final class WebAppMain implements ServletContextListener {
try
{
ServletResponse
.
class
.
getMethod
(
"setCharacterEncoding"
,
String
.
class
);
}
catch
(
NoSuchMethodException
e
)
{
context
.
setAttribute
(
APP
,
new
IncompatibleServletVersionDetected
(
ServletResponse
.
class
));
return
;
throw
new
IncompatibleServletVersionDetected
(
ServletResponse
.
class
);
}
// make sure that we see Ant 1.7
try
{
FileSet
.
class
.
getMethod
(
"getDirectoryScanner"
);
}
catch
(
NoSuchMethodException
e
)
{
context
.
setAttribute
(
APP
,
new
IncompatibleAntVersionDetected
(
FileSet
.
class
));
return
;
throw
new
IncompatibleAntVersionDetected
(
FileSet
.
class
);
}
// make sure AWT is functioning, or else JFreeChart won't even load.
if
(
ChartUtil
.
awtProblemCause
!=
null
)
{
context
.
setAttribute
(
APP
,
new
AWTProblem
(
ChartUtil
.
awtProblemCause
));
return
;
throw
new
AWTProblem
(
ChartUtil
.
awtProblemCause
);
}
// some containers (in particular Tomcat) doesn't abort a launch
...
...
@@ -188,8 +181,7 @@ public final class WebAppMain implements ServletContextListener {
File
f
=
File
.
createTempFile
(
"test"
,
"test"
);
f
.
delete
();
}
catch
(
IOException
e
)
{
context
.
setAttribute
(
APP
,
new
NoTempDir
(
e
));
return
;
throw
new
NoTempDir
(
e
);
}
// Tomcat breaks XSLT with JDK 5.0 and onward. Check if that's the case, and if so,
...
...
@@ -225,12 +217,10 @@ public final class WebAppMain implements ServletContextListener {
LOGGER
.
info
(
"Jenkins is fully up and running"
);
success
=
true
;
}
catch
(
Error
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Failed to initialize Jenkins"
,
e
);
context
.
setAttribute
(
APP
,
new
HudsonFailedToLoad
(
e
));
new
HudsonFailedToLoad
(
e
).
publish
(
context
);
throw
e
;
}
catch
(
Exception
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Failed to initialize Jenkins"
,
e
);
context
.
setAttribute
(
APP
,
new
HudsonFailedToLoad
(
e
));
new
HudsonFailedToLoad
(
e
).
publish
(
context
);
}
finally
{
Jenkins
instance
=
Jenkins
.
getInstance
();
if
(!
success
&&
instance
!=
null
)
...
...
@@ -239,6 +229,8 @@ public final class WebAppMain implements ServletContextListener {
}
};
initThread
.
start
();
}
catch
(
BootFailure
e
)
{
e
.
publish
(
context
);
}
catch
(
Error
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Failed to initialize Jenkins"
,
e
);
throw
e
;
...
...
core/src/main/java/hudson/util/AWTProblem.java
浏览文件 @
729d41cf
...
...
@@ -23,13 +23,18 @@
*/
package
hudson.util
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
/**
* @author Kohsuke Kawaguchi
*/
public
class
AWTProblem
extends
ErrorObject
{
public
class
AWTProblem
extends
BootFailure
{
@Restricted
(
NoExternalUse
.
class
)
@Deprecated
public
final
Throwable
cause
;
public
AWTProblem
(
Throwable
cause
)
{
super
(
cause
);
this
.
cause
=
cause
;
}
}
...
...
core/src/main/java/hudson/util/BootFailure.java
0 → 100644
浏览文件 @
729d41cf
package
hudson.util
;
import
jenkins.util.groovy.GroovyHookScript
;
import
org.kohsuke.stapler.WebApp
;
import
javax.servlet.ServletContext
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
/**
* Indicates a fatal boot problem, among {@link ErrorObject}
*
* @author Kohsuke Kawaguchi
*/
public
abstract
class
BootFailure
extends
ErrorObject
{
protected
BootFailure
()
{
}
protected
BootFailure
(
Throwable
cause
)
{
super
(
cause
);
}
/**
* Exposes this failure to UI and invoke the hook.
*/
public
void
publish
(
ServletContext
context
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Failed to initialize Jenkins"
,
this
);
WebApp
.
get
(
context
).
setApp
(
this
);
new
GroovyHookScript
(
"boot-failure"
)
.
bind
(
"exception"
,
this
)
.
run
();
}
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
BootFailure
.
class
.
getName
());
}
core/src/main/java/hudson/util/ErrorObject.java
浏览文件 @
729d41cf
...
...
@@ -23,6 +23,7 @@
*/
package
hudson.util
;
import
hudson.Functions
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
...
...
@@ -38,7 +39,18 @@ import java.io.IOException;
*
* @author Kohsuke Kawaguchi
*/
public
abstract
class
ErrorObject
{
public
abstract
class
ErrorObject
extends
Exception
{
protected
ErrorObject
()
{
}
protected
ErrorObject
(
Throwable
cause
)
{
super
(
cause
);
}
public
String
getStackTraceString
()
{
return
Functions
.
printThrowable
(
this
);
}
public
void
doDynamic
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
,
InterruptedException
{
rsp
.
setStatus
(
SC_SERVICE_UNAVAILABLE
);
req
.
getView
(
this
,
"index.jelly"
).
forward
(
req
,
rsp
);
...
...
core/src/main/java/hudson/util/HudsonFailedToLoad.java
浏览文件 @
729d41cf
...
...
@@ -23,24 +23,23 @@
*/
package
hudson.util
;
import
hudson.Functions
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
/**
* Model object used to display the generic error when
Hudson
start up fails fatally during initialization.
* Model object used to display the generic error when
Jenkins
start up fails fatally during initialization.
*
* <p>
* <tt>index.jelly</tt> would display a nice friendly error page.
*
* @author Kohsuke Kawaguchi
*/
public
class
HudsonFailedToLoad
extends
ErrorObject
{
public
class
HudsonFailedToLoad
extends
BootFailure
{
@Restricted
(
NoExternalUse
.
class
)
@Deprecated
public
final
Throwable
exception
;
public
HudsonFailedToLoad
(
Throwable
exception
)
{
super
(
exception
);
this
.
exception
=
exception
;
}
public
String
getStackTrace
()
{
return
Functions
.
printThrowable
(
exception
);
}
}
core/src/main/java/hudson/util/IncompatibleAntVersionDetected.java
浏览文件 @
729d41cf
...
...
@@ -37,13 +37,22 @@ import java.net.URL;
*
* @author Kohsuke Kawaguchi
*/
public
class
IncompatibleAntVersionDetected
extends
ErrorObject
{
public
class
IncompatibleAntVersionDetected
extends
BootFailure
{
private
final
Class
antClass
;
public
IncompatibleAntVersionDetected
(
Class
antClass
)
{
this
.
antClass
=
antClass
;
}
@Override
public
String
getMessage
()
{
try
{
return
"Incompatible Ant loaded from "
+
getWhereAntIsLoaded
();
}
catch
(
IOException
e
)
{
return
"Incompatible Ant loaded"
;
}
}
public
URL
getWhereAntIsLoaded
()
throws
IOException
{
return
Which
.
jarURL
(
antClass
);
}
...
...
core/src/main/java/hudson/util/IncompatibleServletVersionDetected.java
浏览文件 @
729d41cf
...
...
@@ -37,7 +37,7 @@ import java.net.URL;
*
* @author Kohsuke Kawaguchi
*/
public
class
IncompatibleServletVersionDetected
extends
ErrorObject
{
public
class
IncompatibleServletVersionDetected
extends
BootFailure
{
private
final
Class
servletClass
;
public
IncompatibleServletVersionDetected
(
Class
servletClass
)
{
...
...
core/src/main/java/hudson/util/IncompatibleVMDetected.java
浏览文件 @
729d41cf
...
...
@@ -34,8 +34,7 @@ import java.util.Map;
*
* @author Kohsuke Kawaguchi
*/
public
class
IncompatibleVMDetected
extends
ErrorObject
{
public
class
IncompatibleVMDetected
extends
BootFailure
{
public
Map
getSystemProperties
()
{
return
System
.
getProperties
();
}
...
...
core/src/main/java/hudson/util/InsufficientPermissionDetected.java
浏览文件 @
729d41cf
...
...
@@ -23,7 +23,8 @@
*/
package
hudson.util
;
import
hudson.Functions
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
/**
* Model object used to display the error top page if
...
...
@@ -34,14 +35,12 @@ import hudson.Functions;
*
* @author Kohsuke Kawaguchi
*/
public
class
InsufficientPermissionDetected
extends
ErrorObject
{
public
class
InsufficientPermissionDetected
extends
BootFailure
{
@Restricted
(
NoExternalUse
.
class
)
@Deprecated
public
final
SecurityException
exception
;
public
InsufficientPermissionDetected
(
SecurityException
e
)
{
super
(
e
);
this
.
exception
=
e
;
}
public
String
getExceptionTrace
()
{
return
Functions
.
printThrowable
(
exception
);
}
}
core/src/main/java/hudson/util/JenkinsReloadFailed.java
浏览文件 @
729d41cf
package
hudson.util
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
/**
* Indicates that Jenkins is interrupted during reload.
*
* @author Kohsuke Kawaguchi
*/
public
class
JenkinsReloadFailed
extends
ErrorObject
{
public
class
JenkinsReloadFailed
extends
BootFailure
{
@Restricted
(
NoExternalUse
.
class
)
@Deprecated
public
final
Throwable
cause
;
public
JenkinsReloadFailed
(
Throwable
cause
)
{
super
(
cause
);
this
.
cause
=
cause
;
}
}
core/src/main/java/hudson/util/NoHomeDir.java
浏览文件 @
729d41cf
...
...
@@ -34,7 +34,7 @@ import java.io.File;
*
* @author Kohsuke Kawaguchi
*/
public
class
NoHomeDir
extends
ErrorObject
{
public
class
NoHomeDir
extends
BootFailure
{
public
final
File
home
;
public
NoHomeDir
(
File
home
)
{
...
...
core/src/main/java/hudson/util/NoTempDir.java
浏览文件 @
729d41cf
...
...
@@ -24,6 +24,8 @@
package
hudson.util
;
import
hudson.Functions
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
java.io.IOException
;
...
...
@@ -36,17 +38,15 @@ import java.io.IOException;
*
* @author Kohsuke Kawaguchi
*/
public
class
NoTempDir
extends
ErrorObject
{
public
class
NoTempDir
extends
BootFailure
{
@Restricted
(
NoExternalUse
.
class
)
@Deprecated
public
final
IOException
exception
;
public
NoTempDir
(
IOException
exception
)
{
super
(
exception
);
this
.
exception
=
exception
;
}
public
String
getStackTrace
()
{
return
Functions
.
printThrowable
(
exception
);
}
public
String
getTempDir
()
{
return
System
.
getProperty
(
"java.io.tmpdir"
);
}
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
729d41cf
...
...
@@ -3086,7 +3086,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
reload
();
}
catch
(
Exception
e
)
{
LOGGER
.
log
(
SEVERE
,
"Failed to reload Jenkins config"
,
e
);
WebApp
.
get
(
servletContext
).
setApp
(
new
JenkinsReloadFailed
(
e
)
);
new
JenkinsReloadFailed
(
e
).
publish
(
servletContext
);
}
}
}.
start
();
...
...
core/src/main/resources/hudson/util/HudsonFailedToLoad/index.jelly
浏览文件 @
729d41cf
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
<l:side-panel />
<l:main-panel>
<h1><img src="${imagesURL}/48x48/error.png" alt="[!]" height="48" width="48"/><st:nbsp/>${%Error}</h1>
<pre>${it.stackTrace}</pre>
<pre>${it.stackTrace
String
}</pre>
</l:main-panel>
</l:layout>
</j:jelly>
core/src/main/resources/hudson/util/InsufficientPermissionDetected/index.jelly
浏览文件 @
729d41cf
...
...
@@ -35,7 +35,7 @@ THE SOFTWARE.
<p>
${%errorMessage.2}
</p>
<pre>${it.
exceptionTrace
}</pre>
<pre>${it.
stackTraceString
}</pre>
</l:main-panel>
</l:layout>
</j:jelly>
core/src/main/resources/hudson/util/JNADoublyLoaded/index.jelly
浏览文件 @
729d41cf
...
...
@@ -30,7 +30,7 @@ THE SOFTWARE.
<l:main-panel>
<h1><img src="${imagesURL}/48x48/error.png" alt="[!]" height="48" width="48"/><st:nbsp/>${%Failed to load JNA}</h1>
<p>${%blurb}</p>
<pre>${it.stackTrace}</pre>
<pre>${it.stackTrace
String
}</pre>
</l:main-panel>
</l:layout>
</j:jelly>
core/src/main/resources/hudson/util/NoTempDir/index.jelly
浏览文件 @
729d41cf
...
...
@@ -30,7 +30,7 @@ THE SOFTWARE.
<l:main-panel>
<h1><img src="${imagesURL}/48x48/error.png" alt="[!]" height="48" width="48"/><st:nbsp/>${%Error}</h1>
<p>${%description(it.tempDir)}</p>
<pre>${it.stackTrace}</pre>
<pre>${it.stackTrace
String
}</pre>
</l:main-panel>
</l:layout>
</j:jelly>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录