@Override
public void actionPerformed(AnActionEvent event) {
Project project = ActionUtil.getProject(event);
String message = "";
final BrowserPanel browserPanel = BrowserPanel.getInstance(project);
try {
Job job = browserPanel.getSelectedJob();
RequestManager requestManager = browserPanel.getJenkinsManager();
if (job.hasParameters()) {
if (job.hasParameter(PARAMETER_NAME)) {
JenkinsAppSettings settings = JenkinsAppSettings.getSafeInstance(project);
final VirtualFile virtualFile =
prepareFile(browserPanel, FileChooser.chooseFile(
browserPanel,
new FileChooserDescriptor(true, false, false, false, false, false))
, settings, job);
if ((null != virtualFile)) {
if (virtualFile.exists()) {
Map<String, VirtualFile> files = new HashMap<String, VirtualFile>();
files.put(PARAMETER_NAME, virtualFile);
requestManager.runBuild(job, settings, files);
notifyOnGoingMessage(job);
browserPanel.loadSelectedJob();
} else {
message = String.format("File \"%s\" not exists", virtualFile.getPath());
}
}
} else {
message = String.format("Job \"%s\" should has parameter with name \"%s\"", job.getName(), PARAMETER_NAME);
}
} else {
message = String.format("Job \"%s\" has no parameters", job.getName());
}
} catch (Exception e) {
message = String.format("Build cannot be run: " + e.getMessage());
e.printStackTrace();
}
if (!message.isEmpty()) {
LOG.info(message);
browserPanel.notifyErrorJenkinsToolWindow(message);
}
}