org.kohsuke.stapler.bind.JavaScriptMethod Java Examples
The following examples show how to use
org.kohsuke.stapler.bind.JavaScriptMethod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IssuesChartPortlet.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Returns the UI model for an ECharts line chart that shows the issues stacked by severity. * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getBuildTrendModel() { SeverityTrendChart severityChart = new SeverityTrendChart(); List<Iterable<? extends BuildResult<AnalysisBuildResult>>> histories = jobs.stream() .filter(job -> job.getLastCompletedBuild() != null) .map(Job::getLastCompletedBuild) .flatMap(build -> build.getActions(ResultAction.class) .stream() .filter(createToolFilter(selectTools, tools))) .map(ResultAction::createBuildHistory).collect(Collectors.toList()); return new JacksonFacade().toJson( severityChart.aggregate(histories, new ChartModelConfiguration(AxisType.DATE))); }
Example #2
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Resets the quality gate for the owner of this view. * * @return unused string (since Firefox requires that Ajax calls return something) */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String resetReference() { RESET_QUALITY_GATE_COMMAND.execute(owner, labelProvider.getId()); return "{}"; }
Example #3
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 5 votes |
@JavaScriptMethod public boolean startOperation(String viewName) { try { convertXmlToDSL(viewName); saveDSLtoFile(); return true; } catch (IOException iosException) { error = "Error getting XML configuration of the job: " + iosException.getLocalizedMessage() + ": " + selectedItems.get(0).getConfigFile().getFile().getParentFile().getParentFile().getParentFile().getAbsolutePath() + File.separator + "userContent" + File.separator + File.separator + DSL_GROOVY; } catch (SAXException | ParserConfigurationException xmlException) { error = "Error parsing XML configuration of the job to DSL"; } return false; }
Example #4
Source File: ResultAction.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Empty method as workaround for Stapler bug: JavaScript method in target object is not found. * * @return unused string (since Firefox requires that Ajax calls return something) */ @JavaScriptMethod @SuppressWarnings("unused") public String resetReference() { // Empty method as workaround for Stapler bug that does not find JavaScript proxy methods in target object IssueDetail return "{}"; }
Example #5
Source File: JobAction.java From warnings-ng-plugin with MIT License | 4 votes |
@JavaScriptMethod @Override public String getBuildTrendModel() { return new JacksonFacade().toJson(createChartModel()); }
Example #6
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public String getNonTranslatedTags() { return nonTranslatedTags; }
Example #7
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public String getParsedItems() { return formatString(parsedItems); }
Example #8
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public void remove(int jobIndex) { remove(allItems.get(jobIndex)); }
Example #9
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public void add(int jobIndex) { add(allItems.get(jobIndex)); }
Example #10
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public int getNumberOfSelectedJobs() { return selectedItems.size(); }
Example #11
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public int getNumberOfJobs() { return allItems.size(); }
Example #12
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public String getError() { return error; }
Example #13
Source File: AggregatedTrendAction.java From warnings-ng-plugin with MIT License | 4 votes |
@JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view @Override public String getBuildTrendModel() { return new JacksonFacade().toJson(createChartModel()); }
Example #14
Source File: JobCollector.java From xml-job-to-job-dsl-plugin with GNU General Public License v3.0 | 4 votes |
@JavaScriptMethod public String getDslFilePath() { return dslFilePath; }
Example #15
Source File: DashboardView.java From jenkins-deployment-dashboard-plugin with MIT License | 4 votes |
@JavaScriptMethod public String deploy(String version, String environment) { LOGGER.info("Deploy version " + version + " to environment " + environment); // Get the environment with corresponding build-job Environment buildEnvironment = null; for (Environment env : environments) { if (env.getAwsInstance().equals(environment)) { buildEnvironment = env; break; } } final AbstractProject buildJob = Jenkins.getInstance().getItemByFullName(buildEnvironment.getBuildJob(), AbstractProject.class); LOGGER.info("Executing job: " + buildJob); if (buildJob == null) { return String.format(Messages.DashboardView_buildJobNotFound(), buildEnvironment.getName()); } if ((!buildJob.isBuildable()) || (!buildJob.isParameterized())) { return Messages.DashboardView_deploymentCannotBeExecuted(); } final ParametersAction versionParam = new ParametersAction(new StringParameterValue(PARAM_VERSION, version)); final ParametersAction environmentParam = new ParametersAction(new StringParameterValue(PARAM_ENVIRONMENT, environment)); final ParametersAction ec2RegionParam = new ParametersAction(new StringParameterValue(PARAM_EC2_REGION, environment)); final ParametersAction awsKeyParam = new ParametersAction(new StringParameterValue(PARAM_AWS_KEY, environment)); List<ParametersAction> actions = Arrays.asList(versionParam, environmentParam, ec2RegionParam, awsKeyParam); QueueTaskFuture<AbstractBuild> scheduledBuild = buildJob.scheduleBuild2(2, new Cause.UserIdCause(), actions); Result result = Result.FAILURE; try { AbstractBuild finishedBuild = scheduledBuild.get(); result = finishedBuild.getResult(); LOGGER.info("Build finished with result: " + result + " completed in: " + finishedBuild.getDurationString() + ". "); } catch (Exception e) { LOGGER.severe("Error while waiting for build " + scheduledBuild.toString() + "."); LOGGER.severe(e.getMessage()); LOGGER.severe(ExceptionUtils.getFullStackTrace(e)); return String.format(Messages.DashboardView_buildJobFailed(), buildJob.getName()); } if (result == Result.SUCCESS) { return String.format(Messages.DashboardView_buildJobScheduledSuccessfully(), buildJob.getName()); } return String.format(Messages.DashboardView_buildJobSchedulingFailed(), buildJob.getName()); }
Example #16
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 4 votes |
/** * Returns the UI model for an ECharts doughnut chart that shows the new, fixed, and outstanding issues. * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getTrendModel() { return JACKSON_FACADE.toJson(new NewVersusFixedPieChart().create(newIssues, outstandingIssues, fixedIssues)); }
Example #17
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 4 votes |
/** * Returns the UI model for an ECharts doughnut chart that shows the severities. * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getSeverityModel() { return JACKSON_FACADE.toJson(new SeverityPieChart().create(report)); }
Example #18
Source File: BuildMonitorView.java From jenkins-build-monitor-plugin with MIT License | 2 votes |
/** * Because of how org.kohsuke.stapler.HttpResponseRenderer is implemented * it can only work with net.sf.JSONObject in order to produce correct application/json output * * @return Json representation of JobViews * @throws Exception */ @JavaScriptMethod public JSONObject fetchJobViews() throws Exception { return Respond.withSuccess(jobViews()); }
Example #19
Source File: IssuesChartPortlet.java From warnings-ng-plugin with MIT License | 2 votes |
/** * Returns the UI model for an ECharts line chart that shows the issues stacked by severity. * * @return the UI model as JSON * @deprecated replaced by {@link #getBuildTrendModel()} which is called from JS file */ @JavaScriptMethod @Deprecated @SuppressWarnings("unused") // Called by jelly view public String getTrend() { return getBuildTrendModel(); }
Example #20
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 2 votes |
/** * Returns the UI model for an ECharts line chart that shows the issues by tool. * * @param isBuildOnXAxis * determines whether the Jenkins build number should be used on the X-axis or the date * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getHealthTrend(final boolean isBuildOnXAxis) { return createTrendAsJson(new HealthTrendChart(healthDescriptor), isBuildOnXAxis); }
Example #21
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 2 votes |
/** * Returns the UI model for an ECharts line chart that shows the new and fixed issues. * * @param isBuildOnXAxis * determines whether the Jenkins build number should be used on the X-axis or the date * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getNewVersusFixedTrend(final boolean isBuildOnXAxis) { return createTrendAsJson(new NewVersusFixedTrendChart(), isBuildOnXAxis); }
Example #22
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 2 votes |
/** * Returns the UI model for an ECharts line chart that shows the issues by tool. * * @param isBuildOnXAxis * determines whether the Jenkins build number should be used on the X-axis or the date * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getToolsTrend(final boolean isBuildOnXAxis) { return createTrendAsJson(new ToolsTrendChart(), isBuildOnXAxis); }
Example #23
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 2 votes |
/** * Returns the UI model for an ECharts line chart that shows the issues stacked by severity. * * @param isBuildOnXAxis * determines whether the Jenkins build number should be used on the X-axis or the date * * @return the UI model as JSON */ @JavaScriptMethod @SuppressWarnings("unused") // Called by jelly view public String getBuildTrend(final boolean isBuildOnXAxis) { return createTrendAsJson(new SeverityTrendChart(), isBuildOnXAxis); }