use of hudson.AbortException in project sonar-scanner-jenkins by SonarSource.
the class SonarRunnerBuilder method perform.
private void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
if (!SonarInstallation.isValid(getInstallationName(), listener)) {
throw new AbortException("Invalid SonarQube server installation");
}
ArgumentListBuilder args = new ArgumentListBuilder();
EnvVars env = BuilderUtils.getEnvAndBuildVars(run, listener);
SonarRunnerInstallation sri = getSonarRunnerInstallation();
if (sri == null) {
// No idea if the path contains old sonar-runner or new sonar-scanner, so prefer the new one
args.add(launcher.isUnix() ? "sonar-scanner" : "sonar-scanner.bat");
} else {
sri = BuilderUtils.getBuildTool(sri, env, listener, workspace);
String exe = sri.getExecutable(launcher);
if (exe == null) {
Logger.printFailureMessage(listener);
String msg = Messages.SonarScanner_ExecutableNotFound(sri.getName());
listener.fatalError(msg);
throw new AbortException(msg);
}
args.add(exe);
}
SonarInstallation sonarInst = getSonarInstallation();
addTaskArgument(args);
addAdditionalArguments(args, sonarInst);
ExtendedArgumentListBuilder argsBuilder = new ExtendedArgumentListBuilder(args, launcher.isUnix());
populateConfiguration(argsBuilder, run, workspace, listener, env, sonarInst);
// Java
computeJdkToUse(run, workspace, listener, env);
// Java options
env.put("SONAR_SCANNER_OPTS", getJavaOpts());
// For backward compatibility with old sonar-runner
env.put("SONAR_RUNNER_OPTS", getJavaOpts());
long startTime = System.currentTimeMillis();
int exitCode;
try {
exitCode = executeSonarQubeScanner(run, workspace, launcher, listener, args, env);
} catch (IOException e) {
handleErrors(listener, sri, startTime, e);
exitCode = -1;
}
// with workflows, we don't have realtime access to build logs, so url might be null
// if the analyis doesn't succeed, it will also be null
SonarUtils.addBuildInfoTo(run, listener, workspace, getSonarInstallation().getName());
if (exitCode != 0) {
throw new AbortException("SonarQube scanner exited with non-zero code: " + exitCode);
}
}
use of hudson.AbortException in project sonar-scanner-jenkins by SonarSource.
the class SonarRunnerBuilder method perform.
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath workspace = build.getWorkspace();
if (workspace == null) {
throw new AbortException("no workspace for " + build);
}
perform(build, workspace, launcher, listener);
return true;
}
use of hudson.AbortException in project nodejs-plugin by jenkinsci.
the class NodeJSBuildWrapper method setUp.
/*
* (non-Javadoc)
* @see jenkins.tasks.SimpleBuildWrapper#setUp(jenkins.tasks.SimpleBuildWrapper.Context, hudson.model.Run, hudson.FilePath, hudson.Launcher, hudson.model.TaskListener, hudson.EnvVars)
*/
@Override
public void setUp(final Context context, Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener, EnvVars initialEnvironment) throws IOException, InterruptedException {
// get specific installation for the node
NodeJSInstallation ni = getNodeJS();
if (ni == null) {
throw new IOException(Messages.NodeJSBuilders_noInstallationFound(nodeJSInstallationName));
}
Computer computer = workspace.toComputer();
if (computer == null) {
throw new AbortException(Messages.NodeJSBuilders_nodeOffline());
}
Node node = computer.getNode();
if (node == null) {
throw new AbortException(Messages.NodeJSBuilders_nodeOffline());
}
ni = ni.forNode(node, listener);
ni = ni.forEnvironment(initialEnvironment);
String exec = ni.getExecutable(launcher);
if (exec == null) {
throw new AbortException(Messages.NodeJSBuilders_noExecutableFound(ni.getHome()));
}
ni.buildEnvVars(new EnvVarsAdapter(context));
EnvVars env = initialEnvironment.overrideAll(context.getEnv());
// add npmrc config
if (configId != null) {
ConfigFile cf = new ConfigFile(configId, null, true);
FilePath configFile = ConfigFileManager.provisionConfigFile(cf, env, build, workspace, listener, new ArrayList<String>());
context.env(NodeJSConstants.NPM_USERCONFIG, configFile.getRemote());
build.addAction(new CleanTempFilesAction(configFile.getRemote()));
}
}
use of hudson.AbortException in project contrast-continuous-application-security-plugin by jenkinsci.
the class VulnerabilityTrendRecorder method perform.
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, final BuildListener listener) throws IOException {
if (!build.isBuilding()) {
return false;
}
VulnerabilityTrendHelper.logMessage(listener, "Checking the number of vulnerabilities for this application.");
ContrastSDK contrastSDK;
Traces traces;
Set<Trace> resultTraces = new HashSet<>();
TeamServerProfile profile = getProfile();
contrastSDK = VulnerabilityTrendHelper.createSDK(profile.getUsername(), profile.getServiceKey(), profile.getApiKey(), profile.getTeamServerUrl());
String applicationId = getApplicationId(contrastSDK, profile.getOrgUuid(), build.getParent().getDisplayName());
if (applicationId.equals("")) {
VulnerabilityTrendHelper.logMessage(listener, "Application with name '" + build.getParent().getDisplayName() + "' not found.");
if (profile.isFailOnWrongApplicationName()) {
throw new AbortException("Application with name '" + build.getParent().getDisplayName() + "' not found.");
}
}
// iterate over conditions; fail on first
for (ThresholdCondition condition : conditions) {
VulnerabilityTrendHelper.logMessage(listener, "Checking the threshold condition where " + condition.toString());
try {
TraceFilterForm filterForm = new TraceFilterForm();
filterForm.setAppVersionTags(Collections.singletonList(VulnerabilityTrendHelper.buildAppVersionTag(build)));
if (condition.getThresholdSeverity() != null) {
filterForm.setSeverities(VulnerabilityTrendHelper.getSeverityList(condition.getThresholdSeverity()));
}
if (condition.getThresholdVulnType() != null) {
filterForm.setVulnTypes(Collections.singletonList(condition.getThresholdVulnType()));
}
traces = contrastSDK.getTracesInOrg(profile.getOrgUuid(), filterForm);
} catch (Exception e) {
VulnerabilityTrendHelper.logMessage(listener, e.getMessage());
throw new AbortException("Unable to retrieve vulnerability information from TeamServer.");
}
resultTraces.addAll(traces.getTraces());
// Integer.parseInt(condition.getThresholdCount());
int thresholdCount = condition.getThresholdCount();
if (traces.getCount() > thresholdCount) {
// save results before failing build
buildResult(resultTraces, build);
throw new AbortException("Failed on the threshold condition where " + condition.toString());
}
}
buildResult(resultTraces, build);
VulnerabilityTrendHelper.logMessage(listener, "This build passes all vulnerability threshold conditions!");
return true;
}
use of hudson.AbortException in project gitea-plugin by jenkinsci.
the class GiteaSCMNavigator method gitea.
private Gitea gitea(SCMSourceOwner owner) throws AbortException {
GiteaServer server = GiteaServers.get().findServer(serverUrl);
if (server == null) {
throw new AbortException("Unknown server: " + serverUrl);
}
StandardCredentials credentials = credentials(owner);
CredentialsProvider.track(owner, credentials);
return Gitea.server(serverUrl).as(AuthenticationTokens.convert(GiteaAuth.class, credentials));
}
Aggregations