Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9 from JordanGS/development-1.1.0-internationaliz…
…ation

Internationalization: JENKINS-43554
  • Loading branch information
JordanGS committed Apr 19, 2017
2 parents 1d55f02 + d395558 commit 317349f
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 124 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/jenkinsci/plugins/zap/ZAPBuilder.java
Expand Up @@ -195,10 +195,10 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
Utils.loggerMessage(listener, 0, "[{0}] END PRE-BUILD ENVIRONMENT VARIABLE REPLACEMENT", Utils.ZAP);
Utils.lineBreak(listener);

/* Clear the ZAP Settings folder of all previous zap logs. */
/* Clear the ZAP home directory of all previous zap logs. */
Utils.loggerMessage(listener, 0, "[{0}] CLEAR LOGS IN SETTINGS...", Utils.ZAP);
Utils.loggerMessage(listener, 1, "SETTINGS DIR [ {0} ]", this.zaproxy.getZapSettingsDir());
Utils.loggerMessage(listener, 1, "WORKSPACE [ {0} ]", build.getWorkspace().getRemote());
Utils.loggerMessage(listener, 1, "ZAP HOME DIRECTORY [ {0} ]", this.zaproxy.getZapSettingsDir());
Utils.loggerMessage(listener, 1, "JENKINS WORKSPACE [ {0} ]", build.getWorkspace().getRemote());

/* No workspace before the first build, so workspace is null. */
FilePath ws = build.getWorkspace();
Expand All @@ -214,7 +214,7 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
e.printStackTrace(); /* No listener because it's not during a build but it's on the job config page. */
}

Utils.loggerMessage(listener, 1, "CLEARING SETTINGS/{0}", ZAPDriver.NAME_LOG_DIR.toUpperCase());
Utils.loggerMessage(listener, 1, "CLEARING ZAP HOME DIRECTORY/{0}", ZAPDriver.NAME_LOG_DIR.toUpperCase());
Utils.lineBreak(listener);

for (File listFile : listFiles) {
Expand Down Expand Up @@ -296,10 +296,10 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
Utils.loggerMessage(listener, 0, "[{0}] SHUTDOWN [ SUCCESSFUL ]", Utils.ZAP);
Utils.lineBreak(listener);

/* Upon ZAP successfully shutting down, copy the files from the ZAP settings directory into the workspace folder. */
/* Upon ZAP successfully shutting down, copy the files from the ZAP home directory into the workspace folder. */
Utils.loggerMessage(listener, 0, "[{0}] LOG SEARCH...", Utils.ZAP);
Utils.loggerMessage(listener, 1, "SETTINGS DIR [ {0} ]", this.zaproxy.getZapSettingsDir());
Utils.loggerMessage(listener, 1, "WORKSPACE [ {0} ]", build.getWorkspace().getRemote());
Utils.loggerMessage(listener, 1, "ZAP HOME DIRECTORY [ {0} ]", this.zaproxy.getZapSettingsDir());
Utils.loggerMessage(listener, 1, "JENKINS WORKSPACE [ {0} ]", build.getWorkspace().getRemote());

/* No workspace before the first build, so workspace is null. */
FilePath ws = build.getWorkspace();
Expand Down Expand Up @@ -383,7 +383,7 @@ public static final class ZAPBuilderDescriptorImpl extends BuildStepDescriptor<B

/* This human readable name is used in the configuration screen. */
@Override
public String getDisplayName() { return "Execute ZAP"; }
public String getDisplayName() { return Messages.jenkins_jobconfig_addbuildstep_zap(); }

@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
Expand Down Expand Up @@ -452,7 +452,7 @@ public void checkRoles(RoleChecker checker) throws SecurityException { /* N/A */
}

/**
* This class allows to search all ZAP log files in the ZAP settings directory of the remote machine (or local machine if there is no remote machine). Returns a list of logs.
* This class allows to search all ZAP log files in the ZAP home directory of the remote machine (or local machine if there is no remote machine). Returns a list of logs.
*/
private static class LogCallable implements FileCallable<File[]> {

Expand Down Expand Up @@ -490,7 +490,7 @@ public void checkRoles(RoleChecker checker) throws SecurityException { /* N/A */
}

/**
* Allows to copy a log file from the ZAP settings directory into the job's workspace.
* Allows to copy a log file from the ZAP home directory into the job's workspace.
*/
private static class CopyFileCallable implements FileCallable<String> {
private static final long serialVersionUID = 1L;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/jenkinsci/plugins/zap/ZAPDriver.java
Expand Up @@ -297,6 +297,8 @@ public ZAPDriver(boolean autoInstall, String toolUsed, String zapHome, String jd
@Override
public String toString() {
String s = "";
s += "\n";
s += "\n";
s += "Admin Configurations\n";
s += "-------------------------------------------------------\n";
s += "zapHost [" + zapHost + "]\n";
Expand All @@ -307,7 +309,7 @@ public String toString() {
s += "jdk [" + jdk + "]\n";
s += "timeout [" + timeout + "]\n";
s += "\n";
s += "ZAP Settings\n";
s += "ZAP Home Directory\n";
s += "-------------------------------------------------------\n";
s += "zapSettingsDir [" + zapSettingsDir + "]\n";
s += "\n";
Expand Down Expand Up @@ -505,8 +507,8 @@ private void checkParams(AbstractBuild<?, ?> build, BuildListener listener) thro
zapProgram = retrieveZapHomeWithToolInstall(build, listener);
Utils.loggerMessage(listener, 0, "[{0}] PLUGIN VALIDATION (PLG), VARIABLE VALIDATION AND ENVIRONMENT INJECTOR EXPANSION (EXP)", Utils.ZAP);

if (this.zapProgram == null || this.zapProgram.isEmpty()) throw new IllegalArgumentException("ZAP PATH IS MISSING, PROVIDED [ " + this.zapProgram + " ]");
else Utils.loggerMessage(listener, 1, "ZAP PATH = [ {0} ]", this.zapProgram);
if (this.zapProgram == null || this.zapProgram.isEmpty()) throw new IllegalArgumentException("ZAP INSTALLATION DIRECTORY IS MISSING, PROVIDED [ " + this.zapProgram + " ]");
else Utils.loggerMessage(listener, 1, "ZAP INSTALLATION DIRECTORY = [ {0} ]", this.zapProgram);

/* System Environment and Build Environment variables will be expanded already, the following step will expand Environment Injector variables. Note: cannot be expanded in pre-build step. */
EnvVars envVars = build.getEnvironment(listener);
Expand Down Expand Up @@ -2803,7 +2805,7 @@ private void getAvailableFormats(ZAPDriverDescriptorImpl zapDriver) {

public String getToolUsed() { return toolUsed; }

private final String zapHome; /* Environment variable for the ZAP path. */
private final String zapHome; /* Environment variable for the ZAP Installation Directory. */

public String getZapHome() { return zapHome; }

Expand Down
@@ -0,0 +1 @@
jenkins.jobconfig.addbuildstep.zap=Execute ZAP
Expand Up @@ -27,8 +27,8 @@ SOFTWARE.
<f:entry help="/descriptor/org.jenkinsci.plugins.zap.ZAPAuthScriptParam/help/config">
<table width="100%">
<tr>
<th>${%Script Parameter Name}</th>
<th>${%Script Parameter Value}</th>
<th>${%jenkins.jobconfig.zap.session.properties.context.authentication.script-based.nameparam.textbox.label}</th>
<th>${%jenkins.jobconfig.zap.session.properties.context.authentication.script-based.valueparam.textbox.label}</th>
</tr>
<tr>
<td><f:textbox field="scriptParameterName"/></td>
Expand Down
@@ -0,0 +1,2 @@
jenkins.jobconfig.zap.session.properties.context.authentication.script-based.nameparam.textbox.label=Script Parameter Name
jenkins.jobconfig.zap.session.properties.context.authentication.script-based.valueparam.textbox.label=Script Parameter Value
Expand Up @@ -26,24 +26,24 @@ SOFTWARE.
<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:section title="${%Admin Configurations}">
<f:entry title="${%Workspace}">
<f:section title="${%jenkins.jobconfig.zap.defaultoverride.section.label}">
<f:entry title="${%jenkins.jobconfig.zap.workspace.label}">
${it.workspace}
</f:entry>

<f:entry title=""></f:entry>

<f:entry title="${%Override Host}" field="zapHost" description="Default Host is : ${descriptor.zapDefaultHost} (${%Configured under 'Manage Jenkins' > 'Configure System'})">
<f:entry title="${%jenkins.jobconfig.zap.defaultoverride.host.textbox.label}" field="zapHost" description="${%jenkins.jobconfig.zap.defaultoverride.host.textbox.description(descriptor.zapDefaultHost)}">
<f:textbox clazz="required" default="${descriptor.zapDefaultHost}" />
</f:entry>

<f:entry title="${%Override Port}" field="zapPort" description="Default Port is : ${descriptor.zapDefaultPort} (${%Configured under 'Manage Jenkins' > 'Configure System'})">
<f:entry title="${%jenkins.jobconfig.zap.defaultoverride.port.textbox.label}" field="zapPort" description="${%jenkins.jobconfig.zap.defaultoverride.port.textbox.description(descriptor.zapDefaultPort)}">
<f:textbox default="${descriptor.zapDefaultPort}" clazz="required" />
</f:entry>
</f:section>

<f:section title="${%Startup}" />
<f:optionalBlock title="${%Run as Pre-Build Step}" field="startZAPFirst" inline="true" />
<f:section title="${%jenkins.jobconfig.zap.startup.section.label}" />
<f:optionalBlock title="${%jenkins.jobconfig.zap.startup.selenium.checkbox.label}" field="startZAPFirst" inline="true" />
<!-- Load the config.jelly bind to ZAPDriver class. This code doesn't work : <st:include page="config.jelly" class="com.github.jenkinsci.zaproxyplugin.ZAPDriver"/>. It doesn't create an ZAPDriver. Use f:property instead. -->
<f:property field="zaproxy" />
</j:jelly>
@@ -0,0 +1,8 @@
jenkins.jobconfig.zap.defaultoverride.section.label=Admin Configurations
jenkins.jobconfig.zap.workspace.label=Workspace
jenkins.jobconfig.zap.defaultoverride.host.textbox.label=Override Host
jenkins.jobconfig.zap.defaultoverride.host.textbox.description=Default Host is : {0} (Configured under 'Manage Jenkins' > 'Configure System')
jenkins.jobconfig.zap.defaultoverride.port.textbox.label=Override Port
jenkins.jobconfig.zap.defaultoverride.port.textbox.description=Default Port is : {0} (Configured under 'Manage Jenkins' > 'Configure System')
jenkins.jobconfig.zap.startup.section.label=Startup
jenkins.jobconfig.zap.startup.selenium.checkbox.label=Run as Pre-Build Step
Expand Up @@ -36,25 +36,25 @@ SOFTWARE.
tags they use. Views are always organized according to its owner class,
so it should be straightforward to find them.
-->
<f:section title="ZAP">
<f:entry title="${%Default Host}" field="zapDefaultHost">
<f:section title="${%jenkins.systemconfig.zap.default.section.label}">
<f:entry title="${%jenkins.systemconfig.zap.default.host.textbox.label}" field="zapDefaultHost">
<f:textbox default="localhost" clazz="required" />
</f:entry>

<f:entry title="${%Default Port}" field="zapDefaultPort">
<f:entry title="${%jenkins.systemconfig.zap.default.port.textbox.label}" field="zapDefaultPort">
<f:textbox default="8090" clazz="required" />
</f:entry>
</f:section>
<f:section title="ZAP JIRA">
<f:entry title="${%JIRA Base Url}" field="jiraBaseURL">
<f:section title="${%jenkins.systemconfig.zap.jira.section.label}">
<f:entry title="${%jenkins.systemconfig.zap.jira.baseurl.textbox.label}" field="jiraBaseURL">
<f:textbox default="" />
</f:entry>

<f:entry title="${%Username}" field="jiraUsername">
<f:entry title="${%jenkins.systemconfig.zap.jira.username.textbox.label}" field="jiraUsername">
<f:textbox default="" />
</f:entry>

<f:entry title="${%Password}" field="jiraPassword">
<f:entry title="${%jenkins.systemconfig.zap.jira.password.textbox.label}" field="jiraPassword">
<f:password default="" />
</f:entry>
</f:section>
Expand Down
@@ -0,0 +1,7 @@
jenkins.systemconfig.zap.default.section.label=ZAP
jenkins.systemconfig.zap.default.host.textbox.label=Default Host
jenkins.systemconfig.zap.default.port.textbox.label=Default Port
jenkins.systemconfig.zap.jira.section.label=ZAP JIRA
jenkins.systemconfig.zap.jira.baseurl.textbox.label=JIRA Base URL
jenkins.systemconfig.zap.jira.username.textbox.label=Username
jenkins.systemconfig.zap.jira.password.textbox.label=Password
Expand Up @@ -27,8 +27,8 @@ SOFTWARE.
<f:entry help="/descriptor/org.jenkinsci.plugins.zap.ZAPCmdLine/help/config">
<table width="100%">
<tr>
<th>${%Command line option}</th>
<th>${%Command line value}</th>
<th>${%jenkins.jobconfig.zap.config.cmdlineargs.optionarg.textbox.label}</th>
<th>${%jenkins.jobconfig.zap.config.cmdlineargs.valuearg.textbox.label}</th>
</tr>
<tr>
<td><f:textbox field="cmdLineOption"/></td>
Expand Down
@@ -0,0 +1,2 @@
jenkins.jobconfig.zap.config.cmdlineargs.optionarg.textbox.label=Command Line Option
jenkins.jobconfig.zap.config.cmdlineargs.valuearg.textbox.label=Command Line Value

0 comments on commit 317349f

Please sign in to comment.