1
JongkinsのログファイルをMongoDBに保存するためのプラグインを作成しようとしています。しかし、私はこれに必要なコンフィグレーションボックスをJenkins Post Buildアクションセクションに表示することができません。 以下は私のコードです。Jenkinsプラグインのビルド:Jenkinsで必要な設定が表示されない
これは私の通知コードです:
public class SaveLogsPublisher extends Notifier {
private final String hostName;
private final String port;
private final boolean saveToMongoDB;
private final String logFilePath;
// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
@DataBoundConstructor
public SaveLogsPublisher(String hostName, String port, boolean saveToMongoDB, String logFilePath) {
this.hostName = hostName;
this.port = port;
this.saveToMongoDB = saveToMongoDB;
this.logFilePath = logFilePath;
}
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.BUILD;
}
/**
* We'll use this from the <tt>config.jelly</tt>.
*/
public String getHostName() {
return hostName;
}
public String getPort() {
return port;
}
public boolean getSaveToMongoDB() {
return saveToMongoDB;
}
public String getLogFilePath() {
return logFilePath;
}
/**
* Save to Mongo DB
*/
@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
return true;
}
// Overridden for better type safety.
// If your plugin doesn't really define any property on Descriptor,
// you don't have to do this.
@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
}
/**
* Descriptor for {@link SaveLogsPublisher}. Used as a singleton.
* The class is marked as public so that it can be accessed from views.
* <p>
* <p>
* See
* for the actual HTML fragment for the configuration screen.
*/
@Extension // This indicates to Jenkins that this is an implementation of an extension point.
public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
/**
* This human readable name is used in the configuration screen.
*/
public String getDisplayName() {
return "Save to Mongo DB";
}
public boolean isApplicable(Class<? extends AbstractProject> aClass) {
// Indicates that this builder can be used with all kinds of project types
return true;
}
}
}
そして、私のConfig.jelly
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<!--
This jelly script is used for per-project configuration.
See global.jelly for a general discussion about jelly script.
-->
<f:entry title="Save to Mongo DB" field="saveToMongoDB" description="Check if we should save the logs to Database.">
<f:checkbox />
</f:entry>
<f:entry title="Mongo DB host" field="hostName" description="Host name of the Mongo DB server">
<f:textbox />
</f:entry>
<f:entry title="Mongo DB Port" field="port" description="Port Number of the MongoDB to be connected">
<f:textbox />
</f:entry>
<f:entry title="Path of Log file" field="logFilePath" description="Full folder path of the jenkins log to be read">
<f:textbox />
</f:entry>
</j:jelly>
しかし、私は私のジェンキンスで見ることができる唯一の事はこれです:
設定ボックスはありません。私はここで何かを逃していますか
これを見つけました。 config.jellyは、クラスと同じパッケージ構造にする必要があります。そしてその**大文字小文字の区別**。 https://stackoverflow.com/questions/29424226/how-does-jenkins-discover-the-config-jelly-for-a-post-build-plugin – Nagendra555