本文整理汇总了Java中com.atlassian.bamboo.task.TaskContext类的典型用法代码示例。如果您正苦于以下问题:Java TaskContext类的具体用法?Java TaskContext怎么用?Java TaskContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskContext类属于com.atlassian.bamboo.task包,在下文中一共展示了TaskContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: publishArtifact
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
@Override
public void publishArtifact(TaskContext taskContext, String name, File directory, String pattern) {
logger.info("publish.artifact", name); //$NON-NLS-1$
ArtifactDefinitionContext artifact = new ArtifactDefinitionContextImpl(name, true, null);
artifact.setCopyPattern(pattern);
ArtifactPublishingResult result = artifactManager.publish(
taskContext.getBuildLogger(),
taskContext.getBuildContext().getPlanResultKey(),
directory,
artifact,
new Hashtable<String, String>(),
1);
taskContext.getBuildContext().getArtifactContext().addPublishingResult(result);
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:19,代码来源:SASTScanTask.java
示例2: createExternalProcessBuilder
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private ExternalProcessBuilder createExternalProcessBuilder(TaskContext taskContext, String... commands) {
ExternalProcessBuilder builder = new ExternalProcessBuilder();
builder.workingDirectory(workingDir);
String appscanOpts = getVariableValue(taskContext, APPSCAN_OPTS);
if (appscanOpts != null)
builder.env(APPSCAN_OPTS, appscanOpts);
List<String> list = new ArrayList<String>();
list.add(utilPath);
list.addAll(Arrays.asList(commands));
builder.command(list);
return builder;
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:17,代码来源:SASTScanner.java
示例3: generateIRX
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
public void generateIRX(TaskContext taskContext, IArtifactPublisher publisher) throws TaskException {
irxBaseName = taskContext.getBuildContext().getBuildResultKey();
logger.info("generate.irx", irxBaseName, workingDir); //$NON-NLS-1$
ExternalProcess process = processService.executeExternalProcess(
taskContext,
createExternalProcessBuilder(
taskContext,
"prepare", //$NON-NLS-1$
"-n", irxBaseName)); //$NON-NLS-1$
publisher.publishArtifact(taskContext, "IRX", workingDir, irxBaseName + "*.*"); //$NON-NLS-1$ //$NON-NLS-2$
int exitCode = process.getHandler().getExitCode();
if (exitCode != 0)
throw new TaskException(logger.getText("generate.irx.failed", exitCode)); //$NON-NLS-1$
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:20,代码来源:SASTScanner.java
示例4: submitIRX
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
public void submitIRX(TaskContext taskContext) throws TaskException {
logger.info("submit.irx"); //$NON-NLS-1$
loginToASoC(taskContext);
String appId = taskContext.getConfigurationMap().get(CFG_APP_ID);
ExternalProcess process = processService.executeExternalProcess(
taskContext,
createExternalProcessBuilder(
taskContext,
"queue_analysis", //$NON-NLS-1$
"-a", appId, //$NON-NLS-1$
"-n", irxBaseName + ".irx")); //$NON-NLS-1$ //$NON-NLS-2$
int exitCode = process.getHandler().getExitCode();
if (exitCode != 0)
throw new TaskException(logger.getText("submit.irx.failed", exitCode)); //$NON-NLS-1$
jobId = getLastLogEntry(taskContext);
if (!jobId.matches("^[-0-9a-zA-Z]+$")) //$NON-NLS-1$
throw new TaskException(logger.getText("submit.irx.failed2")); //$NON-NLS-1$
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:25,代码来源:SASTScanner.java
示例5: pollForStatus
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private JsonNode pollForStatus(TaskContext taskContext) {
processService.executeExternalProcess(
taskContext,
createExternalProcessBuilder(
taskContext,
"info", //$NON-NLS-1$
"-i", jobId, //$NON-NLS-1$
"-json")); //$NON-NLS-1$
try {
return new ObjectMapper().readTree(getLastLogEntry(taskContext));
}
catch (IOException e) {
return null;
}
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:18,代码来源:SASTScanner.java
示例6: waitForReady
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
public void waitForReady(TaskContext taskContext) throws TaskException, InterruptedException {
int consecFails = 0;
for (;;) {
Thread.sleep(getTimeToSleep(taskContext) * 1000L);
try {
if (isReady(taskContext))
return;
consecFails = 0;
}
catch (StatusCheckException e) {
if (++consecFails == MAX_CONSEC_FAILS)
throw e;
}
}
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:21,代码来源:SASTScanner.java
示例7: downloadResult
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
public void downloadResult(TaskContext taskContext, IArtifactPublisher publisher) throws TaskException {
logger.info("download.result"); //$NON-NLS-1$
String html = irxBaseName + ".html"; //$NON-NLS-1$
ExternalProcess process = processService.executeExternalProcess(
taskContext,
createExternalProcessBuilder(
taskContext,
"get_result", //$NON-NLS-1$
"-i", jobId, //$NON-NLS-1$
"-d", html)); //$NON-NLS-1$
publisher.publishArtifact(taskContext, logger.getText("result.artifact"), workingDir, html); //$NON-NLS-1$
int exitCode = process.getHandler().getExitCode();
if (exitCode != 0)
throw new TaskException(logger.getText("download.result.failed", exitCode)); //$NON-NLS-1$
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:21,代码来源:SASTScanner.java
示例8: publishRiskReportFiles
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private void publishRiskReportFiles(final IntLogger logger, final TaskContext taskContext, final SecureToken token, final RiskReportDataService riskReportDataService, final ProjectView project, final ProjectVersionView version) {
final BuildContext buildContext = taskContext.getBuildContext();
final PlanResultKey planResultKey = buildContext.getPlanResultKey();
final BuildLogger buildLogger = taskContext.getBuildLogger();
try {
final File baseDirectory = new File(taskContext.getWorkingDirectory(), HubBambooUtils.HUB_RISK_REPORT_ARTIFACT_NAME);
riskReportDataService.createReportFiles(baseDirectory, project, version);
final Map<String, String> config = new HashMap<>();
final ArtifactDefinitionContext artifact = createArtifactDefContext(token);
final ArtifactPublishingResult publishResult = artifactManager.publish(buildLogger, planResultKey, baseDirectory, artifact, config, RISK_REPORT_MINIMUM_FILE_COUNT);
if (!publishResult.shouldContinueBuild()) {
logger.error("Could not publish the artifacts for the Risk Report");
}
cleanupReportFiles(baseDirectory);
} catch (final IntegrationException ex) {
logger.error("Could not publish the Risk Report", ex);
}
}
开发者ID:blackducksoftware,项目名称:hub-bamboo,代码行数:21,代码来源:HubScanTask.java
示例9: execute
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
public TaskResult execute(final TaskContext taskContext)
throws TaskException {
Build build = new Build(taskContext);
init(taskContext, build);
buildLogger = taskContext.getBuildLogger();
TaskResultBuilder builder = TaskResultBuilder.newBuilder(taskContext);
ProcessHandler packaging = processHandlerService.packaging();
packaging.execute();
if (packaging.hasFailed()) {
return builder.failedWithError().build();
}
else {
return builder.checkReturnCode(packaging.getExternalProcess()).build();
}
}
开发者ID:zend-patterns,项目名称:ZendServerBamboo,代码行数:20,代码来源:PackagingTask.java
示例10: init
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
public void init(TaskContext taskContext, BuildEnv buildEnv) {
buildLogger = taskContext.getBuildLogger();
processService = new ProcessService();
processService.setCapabilityContext(capabilityContext);
processService.setConfigMap(taskContext.getConfigurationMap());
processService.setBuildEnv(buildEnv);
processHandlerService = new ProcessHandlerService();
processHandlerService.setProcessService(processService);
processHandlerService.setBuildEnv(buildEnv);
processHandlerService.setBuildLogger(buildLogger);
errorCollatorListener = getBuildErrorCollator();
errorCollatorListener.setTaskContext(taskContext);
tests = new Tests();
tests.setListener(errorCollatorListener);
}
开发者ID:zend-patterns,项目名称:ZendServerBamboo,代码行数:20,代码来源:BaseTask.java
示例11: execute
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
@Override
public TaskResult execute(TaskContext context) throws TaskException {
TaskResultBuilder resultBuilder = TaskResultBuilder.create(context);
final BuildLogger logger = context.getBuildLogger();
logger.addBuildLogEntry("Executing BlazeMeter task...");
logger.addBuildLogEntry("BlazemeterBamboo plugin v." + Utils.getVersion());
BambooCiBuild build = null;
FileHandler logHandler = null;
BuildResult buildResult = null;
try {
logHandler = setUpLogFileHandler(context);
build = setUpCiBuild(context, logHandler);
buildResult = build.execute();
} catch (Exception e) {
logger.addErrorLogEntry("Failed to start build: ",e);
return resultBuilder.failed().build();
} finally {
logHandler.close();
}
switch (buildResult) {
case FAILED:
return resultBuilder.failed().build();
case ERROR:
return resultBuilder.failedWithError().build();
case SUCCESS:
return resultBuilder.success().build();
default:
return resultBuilder.success().build();
}
}
开发者ID:Blazemeter,项目名称:blazemeter-bamboo-plugin,代码行数:31,代码来源:TaskType.java
示例12: setUpBzmUtils
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private BambooBzmUtils setUpBzmUtils(TaskContext context, FileHandler logHandler) throws TaskException {
List<TaskDefinition> tds = context.getBuildContext().getBuildDefinition().getTaskDefinitions();
final BuildLogger logger = context.getBuildLogger();
String apiId = null;
String apiSecret = null;
String url = null;
for (TaskDefinition d : tds) {
if (d.getPluginKey().equals(Constants.PLUGIN_KEY)) {
Map<String, String> conf = d.getConfiguration();
apiId = conf.get(AdminServlet.API_ID);
apiSecret = conf.get(AdminServlet.API_SECRET);
url = conf.get(AdminServlet.URL);
}
}
if (StringUtils.isBlank(apiId)) {
logger.addBuildLogEntry("BlazeMeter user key not defined!");
throw new TaskException("BlazeMeter user key not defined!");
}
UserNotifier notifier = new AgentUserNotifier(logger);
Logger log = new AgentLogger(logHandler);
BambooBzmUtils utils = new BambooBzmUtils(apiId, apiSecret, url, url, notifier, log);
return utils;
}
开发者ID:Blazemeter,项目名称:blazemeter-bamboo-plugin,代码行数:25,代码来源:TaskType.java
示例13: setUpLogFileHandler
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private FileHandler setUpLogFileHandler(TaskContext context) throws Exception {
File dd = new File(context.getWorkingDirectory().getAbsolutePath() + "/build # "
+ context.getBuildContext().getBuildNumber());
String log = dd + File.separator + Constants.HTTP_LOG;
File logFile = new File(log);
BuildLogger buildLogger = context.getBuildLogger();
try {
logFile.getParentFile().mkdirs();
logFile.createNewFile();
} catch (Exception e) {
buildLogger.addBuildLogEntry("Failed to create log file = " + log);
logFile = new File(context.getWorkingDirectory().getAbsolutePath(), File.separator + Constants.HTTP_LOG);
try {
buildLogger.addBuildLogEntry("Log will be written to " + logFile.getAbsolutePath());
logFile.createNewFile();
} catch (Exception ex) {
buildLogger.addBuildLogEntry("Failed to create log file = " + logFile.getAbsolutePath());
throw e;
}
}
FileHandler bzm = new FileHandler(log);
return bzm;
}
开发者ID:Blazemeter,项目名称:blazemeter-bamboo-plugin,代码行数:24,代码来源:TaskType.java
示例14: execute
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
@Override
protected TaskResult execute(final TaskContext taskContext, final VirtualMachine vm) throws Throwable
{
final BuildLogger buildLogger = taskContext.getBuildLogger();
final String name = vm.getName();
VirtualMachineRuntimeInfo vmri = (VirtualMachineRuntimeInfo) vm.getRuntime();
if (vmri.getPowerState() == VirtualMachinePowerState.poweredOff) {
buildLogger.addBuildLogEntry("The virtual machine '" + name + "' is already in a powered off state.");
return TaskResultBuilder.create(taskContext).success().build();
}
buildLogger.addBuildLogEntry("Requesting that the virtual machine '" + name + "' power off.");
Task task = vm.powerOffVM_Task();
if(task.waitForMe()==Task.SUCCESS) {
buildLogger.addBuildLogEntry("The virtual machine '" + name + "' has was succesfully powered off.");
}
else {
buildLogger.addBuildLogEntry("Failed to power off the virtual machine '" + name + "'.");
}
return TaskResultBuilder.create(taskContext).success().build();
}
开发者ID:bloudraak,项目名称:blueprint-bamboo-vmware-tasks,代码行数:23,代码来源:PowerOffVirtualMachineTask.java
示例15: setUsernameAndPassword
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private void setUsernameAndPassword(TaskContext taskContext) {
String id = taskContext.getConfigurationMap().get(CFG_SELECTED_CRED);
CredentialsData credentials = credentialsManager.getCredentials(Long.parseLong(id));
String username = credentials.getConfiguration().get("username"); //$NON-NLS-1$
scanner.setUsername(username);
String password = credentials.getConfiguration().get("password"); //$NON-NLS-1$
scanner.setPassword(password);
// this ensures password is masked in build log
taskContext.getBuildContext().getVariableContext().addLocalVariable("asoc_password", password); //$NON-NLS-1$
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:15,代码来源:SASTScanTask.java
示例16: copyArtifacts
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private File copyArtifacts(TaskContext taskContext) throws TaskException {
File workingDir = taskContext.getWorkingDirectory();
File dirToScan = new File(workingDir, SA_DIR);
if (dirToScan.exists())
FileUtils.deleteDir(dirToScan);
dirToScan.mkdirs();
Collection<ArtifactDefinitionContext> artifacts = taskContext.getBuildContext().getArtifactContext().getDefinitionContexts();
if (artifacts.isEmpty())
throw new TaskException(logger.getText("err.no.artifacts")); //$NON-NLS-1$
try {
for (ArtifactDefinitionContext artifact : artifacts) {
logger.info("copy.artifact", artifact.getName(), dirToScan); //$NON-NLS-1$
FileSet fileSet = ArtifactHandlingUtils.createFileSet(workingDir, artifact, true, null);
ArtifactHandlingUtils.copyFileSet(fileSet, dirToScan);
}
return dirToScan;
}
catch (IOException e) {
throw new TaskException(e.getLocalizedMessage(), e);
}
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:29,代码来源:SASTScanTask.java
示例17: execute
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
@Override
public TaskResult execute(TaskContext taskContext) throws TaskException {
logger.setLogger(taskContext.getBuildLogger());
setUsernameAndPassword(taskContext);
scanner.setWorkingDir(copyArtifacts(taskContext));
scanner.setUtilPath(getUtilPath(taskContext));
scanner.generateIRX(taskContext, this);
scanner.submitIRX(taskContext);
TaskResultBuilder result = TaskResultBuilder.newBuilder(taskContext);
try {
if (taskContext.getConfigurationMap().getAsBoolean(CFG_SUSPEND)) {
scanner.waitForReady(taskContext);
scanner.downloadResult(taskContext, this);
return calculateResult(taskContext, result).build();
}
return result.success().build();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
return result.failedWithError().build();
}
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:30,代码来源:SASTScanTask.java
示例18: getVariableValue
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private String getVariableValue(TaskContext taskContext, String name) {
VariableContext variables = taskContext.getBuildContext().getVariableContext();
VariableDefinitionContext variable = variables.getEffectiveVariables().get(name);
return variable == null ? null : variable.getValue();
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:6,代码来源:SASTScanner.java
示例19: getLastLogEntry
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private String getLastLogEntry(TaskContext taskContext) {
List<LogEntry> logs = taskContext.getBuildLogger().getLastNLogEntries(2);
Collections.reverse(logs);
String text = ""; //$NON-NLS-1$
for (LogEntry log : logs) {
text = log.getUnstyledLog();
if (!text.trim().isEmpty())
break;
}
return text;
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:16,代码来源:SASTScanner.java
示例20: loginToASoC
import com.atlassian.bamboo.task.TaskContext; //导入依赖的package包/类
private void loginToASoC(TaskContext taskContext) {
processService.executeExternalProcess(
taskContext,
createExternalProcessBuilder(
taskContext,
"api_login", //$NON-NLS-1$
"-u", username, //$NON-NLS-1$
"-P", password, //$NON-NLS-1$
"-persist")); //$NON-NLS-1$
}
开发者ID:AppSecDev,项目名称:asoc-bamboo-plugin,代码行数:11,代码来源:SASTScanner.java
注:本文中的com.atlassian.bamboo.task.TaskContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论