本文整理汇总了Java中hudson.model.BuildListener类的典型用法代码示例。如果您正苦于以下问题:Java BuildListener类的具体用法?Java BuildListener怎么用?Java BuildListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildListener类属于hudson.model包,在下文中一共展示了BuildListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkProjectKeyIfVariable
import hudson.model.BuildListener; //导入依赖的package包/类
public JobConfigData checkProjectKeyIfVariable(JobConfigData jobConfigData, AbstractBuild build, BuildListener listener) throws QGException {
String projectKey = jobConfigData.getProjectKey();
if (projectKey.isEmpty()) {
throw new QGException("Empty project key.");
}
final JobConfigData envVariableJobConfigData = new JobConfigData();
envVariableJobConfigData.setSonarInstanceName(jobConfigData.getSonarInstanceName());
try {
envVariableJobConfigData.setProjectKey(getProjectKey(projectKey, build.getEnvironment(listener)));
} catch (IOException | InterruptedException e) {
throw new QGException(e);
}
envVariableJobConfigData.setSonarInstanceName(jobConfigData.getSonarInstanceName());
return envVariableJobConfigData;
}
示例2: perform
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
// Get VSO build environments
Map<String, String> env = build.getBuildVariables();
String tfsBuildIdStr = env.get("TfsBuildId" + build.getId());
// No build was queued on tfs, return
if (tfsBuildIdStr == null) {
return false;
}
int tfsBuildId = Integer.parseInt(tfsBuildIdStr);
try {
TfsClient client = getTfsClientFactory().getValidatedClient(this.serverUrl, this.username, this.password);
TfsBuildFacade tfsBuildFacade = getTfsBuildFacadeFactory().getBuildOnTfs(tfsBuildId, build, client);
tfsBuildFacade.finishAllTaskRecords();
tfsBuildFacade.finishBuild();
} catch (Exception e) {
e.printStackTrace();
logger.severe(e.getMessage());
return false;
}
return true;
}
示例3: perform
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener) throws InterruptedException, IOException {
EnvVars envVars = build.getEnvironment(listener);
String expandedFilename = envVars.expand(filename);
String expandedContent = envVars.expand(content);
FilePath file = build.getWorkspace().child(expandedFilename);
file.write(expandedContent, encoding);
return true;
}
示例4: perform
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
throws InterruptedException, IOException {
for (Cause.UpstreamCause c: Util.filter(build.getCauses(), Cause.UpstreamCause.class)) {
Job<?,?> upstreamProject = Jenkins.getInstance().getItemByFullName(c.getUpstreamProject(), Job.class);
if (upstreamProject == null) {
listener.getLogger().println(String.format("Not Found: %s", c.getUpstreamProject()));
continue;
}
Run<?,?> upstreamBuild = upstreamProject.getBuildByNumber(c.getUpstreamBuild());
if (upstreamBuild == null) {
listener.getLogger().println(String.format("Not Found: %s - %d", upstreamProject.getFullName(), c.getUpstreamBuild()));
continue;
}
listener.getLogger().println(String.format("Removed: %s - %s", upstreamProject.getFullName(), upstreamBuild.getFullDisplayName()));
upstreamBuild.delete();
}
return true;
}
示例5: perform
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
//To change body of generated methods, choose Tools | Templates.
LogOutput log = new LogOutput();
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
String script = generateScript();
process = runScript(runtime, script);
log.logOutput(listener, process);
} catch (Throwable cause) {
log.logOutput(listener, process);
}
return true;
}
示例6: parseBuildParams
import hudson.model.BuildListener; //导入依赖的package包/类
private void parseBuildParams(AbstractBuild<?, ?> build, BuildListener listener) throws IOException, InterruptedException {
final EnvVars envVars = build.getEnvironment(listener);
final VariableResolver<String> buildVariableResolver = build.getBuildVariableResolver();
clearEvaluated();
evaluatedJaasEndpoint = evaluate(jaasEndpoint, buildVariableResolver, envVars);
evaluatedTestProjectUrl = evaluate(testProjectUrl, buildVariableResolver, envVars);
evaluatedEnvId = evaluate(envId, buildVariableResolver, envVars);
evaluatedLoadScenarioId = evaluate(loadScenarioId, buildVariableResolver, envVars);
evaluatedTimeout = evaluate(executionStartTimeoutInSeconds, buildVariableResolver, envVars);
}
示例7: newTelegramService
import hudson.model.BuildListener; //导入依赖的package包/类
public TelegramService newTelegramService(AbstractBuild r, BuildListener listener) {
String authToken = this.authToken;
if (StringUtils.isEmpty(authToken)) {
authToken = getDescriptor().getToken();
}
String chatId = this.chatId;
if (StringUtils.isEmpty(chatId)) {
chatId = getDescriptor().getChatId();
}
EnvVars env = null;
try {
env = r.getEnvironment(listener);
} catch (Exception e) {
listener.getLogger().println("Error retrieving environment vars: " + e.getMessage());
env = new EnvVars();
}
authToken = env.expand(authToken);
chatId = env.expand(chatId);
return new StandardTelegramService(authToken, chatId);
}
示例8: perform
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
throws InterruptedException, IOException {
try {
GoogleRobotCredentials credentials = GoogleRobotCredentials.getById(getCredentialsId());
GoogleDriveManager driveManager = new GoogleDriveManager(authorize(credentials));
String pattern = Util.replaceMacro(getPattern(), build.getEnvironment(listener));
String workspace = build.getWorkspace().getRemote();
String[] filesToUpload = listFiles(workspace, pattern);
for (String file : filesToUpload) {
listener.getLogger().println("Uploading file: " + file);
driveManager.store(file, getDriveLocation());
}
} catch (GeneralSecurityException e) {
build.setResult(Result.FAILURE);
return false;
}
return true;
}
示例9: setUp
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public Environment setUp(final AbstractBuild build, final Launcher launcher,
final BuildListener listener) throws IOException, InterruptedException {
final PrintStream logger = listener.getLogger();
final BrowserStackCredentials credentials = BrowserStackCredentials.getCredentials(build.getProject(), credentialsId);
if (credentials != null) {
this.username = credentials.getUsername();
this.accesskey = credentials.getDecryptedAccesskey();
}
AutomateBuildEnvironment buildEnv = new AutomateBuildEnvironment(credentials, launcher, logger);
if (accesskey != null && this.localConfig != null) {
try {
buildEnv.startBrowserStackLocal(build.getFullDisplayName());
} catch (Exception e) {
listener.fatalError(e.getMessage());
throw new IOException(e.getCause());
}
}
recordBuildStats();
return buildEnv;
}
示例10: perform
import hudson.model.BuildListener; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath workspace = build.getWorkspace();
workspace.child(this.finalReportDir).mkdirs();
OutputStream outputStream = null;
InputStream inputStream = null;
try {
outputStream = workspace.child(this.finalReportDir + this.resourceFileToCopy).write();
inputStream = this.getClass().getClassLoader().getResourceAsStream(this.resourceFileToCopy);
IOUtils.copy(inputStream, outputStream);
} finally {
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
}
return true;
}
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:17,代码来源:CopyResourceFileToWorkspaceTarget.java
示例11: setUp
import hudson.model.BuildListener; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public EphemeralDeployment setUp(AbstractBuild build, Launcher launcher, BuildListener listener)
throws IOException, InterruptedException {
EnvVars environment = build.getEnvironment(listener);
FilePath workspace = requireNonNull(build.getWorkspace());
try {
synchronized (deployment) {
deployment.insert(workspace, environment, listener.getLogger());
}
} catch (CloudManagementException e) {
e.printStackTrace(listener.error(e.getMessage()));
return null; // Build must be aborted
}
return new EphemeralDeployment(environment);
}
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:21,代码来源:GoogleCloudManagerBuildWrapper.java
示例12: getEnvironmentExceptionTest
import hudson.model.BuildListener; //导入依赖的package包/类
@Test
public void getEnvironmentExceptionTest() throws Exception {
GoogleCloudManagerDeployer deployer =
new GoogleCloudManagerDeployer(getNewTestingTemplatedCloudDeployment(credentials.getId(),
DEPLOYMENT_NAME, CONFIG_FILE, PathUtils.toRemotePaths(importPaths), null));
BuildListener listener = mock(BuildListener.class);
PrintStream printStream = new PrintStream(new ByteArrayOutputStream());
when(listener.getLogger()).thenReturn(printStream);
when(listener.error(any(String.class))).thenReturn(new PrintWriter(printStream));
AbstractBuild build = mock(AbstractBuild.class);
when(build.getResult()).thenReturn(Result.SUCCESS);
when(build.getEnvironment(listener)).thenThrow(new IOException("test"));
// Check that we failed the build step due to a failure to retrieve
// the environment.
assertFalse(deployer.perform(build, null, listener));
}
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:20,代码来源:GoogleCloudManagerDeployerTest.java
示例13: initialize
import hudson.model.BuildListener; //导入依赖的package包/类
private void initialize(AbstractBuild<?, ?> build, BuildListener listener) throws FileNotFoundException, IOException, InterruptedException {
this.sharedResourceEntityList = new ArrayList<>();
Map<String, String> envVars = build.getEnvironment(listener);
workspaceHelper = new WorkspaceHelper(envVars.get("WORKSPACE"));
String tempFolderPath = workspaceHelper.getTempFolderPath();
// if the directory does not exist, create it else detlete it
if (Utils.dirExists(tempFolderPath)) {
Logger.log(listener, workspaceHelper.getTempFolderPath() + " already exist.. deleting it");
Utils.deleteDirectoryIncludeContent(tempFolderPath);
}
Logger.log(listener, "Creating directory: " + tempFolderPath);
Files.createDirectory(Paths.get(tempFolderPath));
if (Utils.dirExists(tempFolderPath)) {
Logger.log(listener, workspaceHelper.getTempFolderPath() + " got created");
}
else
{
throw new FileNotFoundException(String.format("Directory %s doesn't exist", tempFolderPath));
}
}
示例14: JobGenerator
import hudson.model.BuildListener; //导入依赖的package包/类
JobGenerator(BuildListener listener, WorkspaceHelper workspaceHelper,
ProjectConfigHelper projectConfigHelper, JobSplitterHelper jobSplitterHelper, List<ResourceEntity> sharedResourceEntityList,
BatchClient client, String jobId, String poolId,
StorageAccountInfo storageAccountInfo, String containerSasKey) throws URISyntaxException, StorageException, InvalidKeyException, IOException {
this.listener = listener;
this.workspaceHelper = workspaceHelper;
this.projectConfigHelper = projectConfigHelper;
this.jobSplitterHelper = jobSplitterHelper;
this.sharedResourceEntityList = sharedResourceEntityList;
this.client = client;
this.jobId = jobId;
this.poolId = poolId;
this.storageAccountInfo = storageAccountInfo;
this.containerSasKey = containerSasKey;
scriptTempFolder = workspaceHelper.getPathRelativeToTempFolder("scripts");
if (!Utils.dirExists(scriptTempFolder)) {
Files.createDirectory(Paths.get(scriptTempFolder));
}
}
示例15: generateProjectConfig
import hudson.model.BuildListener; //导入依赖的package包/类
/**
* Generate project config
* @param listener BuildListener
* @param fullFilePath full file path of project config file
* @return ProjectConfig instance
* @throws IOException
*/
public static ProjectConfig generateProjectConfig(BuildListener listener, String fullFilePath) throws IOException
{
Logger.log(listener, "Reading project configurations from %s...", fullFilePath);
if (!Utils.fileExists(fullFilePath)) {
throw new IOException(String.format("Project config file '%s' doesn't exist, please double check your configuration.", fullFilePath));
}
Gson gson = new Gson();
ProjectConfig config = null;
try (Reader reader = new InputStreamReader(new FileInputStream(new File(fullFilePath)), Charset.defaultCharset())) {
config = gson.fromJson(reader, ProjectConfig.class);
}
// TODO: validate against schema
// Do some basic check for project config, in case customer may provide wrong config file.
basicCheckProjectConfig(config);
Logger.log(listener, "Created project config from config %s", fullFilePath);
return config;
}