本文整理汇总了Java中hudson.model.TaskListener类的典型用法代码示例。如果您正苦于以下问题:Java TaskListener类的具体用法?Java TaskListener怎么用?Java TaskListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskListener类属于hudson.model包,在下文中一共展示了TaskListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCommitRange
import hudson.model.TaskListener; //导入依赖的package包/类
private List<String> getCommitRange(
Run<?, ?> build,
FilePath workspace,
Launcher launcher,
TaskListener listener,
String fromRevision,
String toRevision) throws IOException, InterruptedException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
launcher.launch()
.cmdAsSingleString(String.format("git log --pretty='%%H' %s..%s", fromRevision, toRevision))
.pwd(workspace)
.envs(build.getEnvironment(listener))
.stdout(out)
.join();
ArrayList<String> revisions = new ArrayList<>();
for (String line : out.toString("UTF8").split("\n")) {
String trimmed = line.trim();
if (!trimmed.isEmpty()) {
revisions.add(trimmed);
}
}
return revisions;
}
示例2: cloneConfigRepo
import hudson.model.TaskListener; //导入依赖的package包/类
/**
* Clones a GIT repo into configRepo directory in workspace
*
* @param build Build
* @param workspace Jenkins job workspace
* @param listener Task listener
* @throws InterruptedException InterruptedException
* @throws IOException IOException
*/
public void cloneConfigRepo(Run<?,?> build, FilePath workspace, TaskListener listener)
throws IOException, InterruptedException {
boolean status = true;
listener.getLogger().println(">> Cloning warhornConfigRepo: " + gitConfigUrl + " to " +
workspace.getRemote() + "/configRepo");
// Repo will be cloned inside configRepo directory
FilePath ws = new FilePath(workspace, "configRepo");
if(ws.exists()){
ws.deleteRecursive();
}
File localPath = new File(ws.toURI());
// Perform clone operation in Workspace(Master/Slave)
status = workspace.act(new GitCallable(this, localPath, listener));
if (status != true) {
throw new InterruptedException("Cloning warhornConfigRepo: " + gitConfigUrl + " failed");
}
}
示例3: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Void> builder = ResponseData.builder();
when(hubotServiceMock.sendMessage(anyString(), anyString()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(envVarsMock.get("HUBOT_URL")).thenReturn("http://localhost:9090/");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:9090/hubot-testing/job/01");
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例4: retrieveActions
import hudson.model.TaskListener; //导入依赖的package包/类
@NonNull
@Override
protected List<Action> retrieveActions(SCMSourceEvent event, @NonNull TaskListener listener)
throws IOException, InterruptedException {
if (giteaRepository == null) {
try (GiteaConnection c = gitea().open()) {
listener.getLogger().format("Looking up repository %s/%s%n", repoOwner, repository);
giteaRepository = c.fetchRepository(repoOwner, repository);
}
}
List<Action> result = new ArrayList<>();
result.add(new ObjectMetadataAction(null, giteaRepository.getDescription(), giteaRepository.getWebsite()));
result.add(new GiteaLink("icon-gitea-repo", UriTemplate.buildFromTemplate(serverUrl)
.path(UriTemplateBuilder.var("owner"))
.path(UriTemplateBuilder.var("repository"))
.build()
.set("owner", repoOwner)
.set("repository", repository)
.expand()
));
return result;
}
示例5: uploadWarriorLog
import hudson.model.TaskListener; //导入依赖的package包/类
/**
* Uploads Warrior Execution Logs to remote server
*
* @param build Build
* @param workspace Jenkins job workspace
* @param listener Task listener
* @throws InterruptedException InterruptedException
* @throws IOException IOException
* @throws SAXException SAXException
* @throws ParserConfigurationException ParserConfigurationException
*/
private void uploadWarriorLog(Run<?,?> build, FilePath workspace, TaskListener listener)
throws IOException, InterruptedException, ParserConfigurationException, SAXException {
boolean status = true;
listener.getLogger().println(">> Uploading warrior execution logs");
File execLogFolder = new File(workspace.getRemote(), "/WarriorFramework/warrior/Warriorspace/Execution");
String buildTag = build.getEnvironment(listener).get("BUILD_TAG");
File execLogZip = new File(workspace.getRemote(), "/WarriorFramework/warrior/Warriorspace/Execution_"+ buildTag + ".zip");
status = workspace.act(new FileUploadCallable(this, execLogFolder, execLogZip, listener));
if (status != true) {
throw new InterruptedException("Uploading warrior execution logs failed");
} else {
listener.getLogger().println(">> Successfully uploaded Warrior Execution logs to : " +
uploadServerIp + ":" + uploadServerDir + "/Execution_"+ buildTag + ".zip");
//(sftp)logger.println("Uploaded Warrior Execution logs to : " + uploadServerIp + "://" + uploadServerDir);
//(ftp)logger.println("Uploaded Warrior Execution logs: " + uploadServerUname + "@" + uploadServerIp + "/" + uploadServerDir);
}
}
示例6: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
// Prepare site.
when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");
PowerMockito.mockStatic(Site.class);
Mockito.when(Site.get(any())).thenReturn(siteMock);
when(siteMock.getService()).thenReturn(jiraServiceMock);
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Void> builder = ResponseData.builder();
when(jiraServiceMock.addIssueWatcher(anyString(), anyString()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例7: onFailure
import hudson.model.TaskListener; //导入依赖的package包/类
@Override public void onFailure(StepContext context, Throwable t) {
try {
TaskListener listener = context.get(TaskListener.class);
Result r = Result.FAILURE;
if (t instanceof AbortException) {
listener.error(t.getMessage());
} else if (t instanceof FlowInterruptedException) {
FlowInterruptedException fie = (FlowInterruptedException) t;
fie.handle(context.get(Run.class), listener);
r = fie.getResult();
} else {
listener.getLogger().println(Functions.printThrowable(t).trim()); // TODO 2.43+ use Functions.printStackTrace
}
context.get(Run.class).setResult(r);
context.onSuccess(null);
} catch (Exception x) {
context.onFailure(x);
}
}
示例8: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
// Prepare site.
when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");
PowerMockito.mockStatic(Site.class);
Mockito.when(Site.get(any())).thenReturn(siteMock);
when(siteMock.getService()).thenReturn(jiraServiceMock);
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Void> builder = ResponseData.builder();
when(jiraServiceMock.linkIssues(anyString(), anyString(), anyString(), anyString()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例9: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
// Prepare site.
when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");
PowerMockito.mockStatic(Site.class);
Mockito.when(Site.get(any())).thenReturn(siteMock);
when(siteMock.getService()).thenReturn(jiraServiceMock);
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Object> builder = ResponseData.builder();
when(jiraServiceMock.getIssue(anyString()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例10: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
// Prepare site.
when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");
PowerMockito.mockStatic(Site.class);
Mockito.when(Site.get(any())).thenReturn(siteMock);
when(siteMock.getService()).thenReturn(jiraServiceMock);
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Object> builder = ResponseData.builder();
when(jiraServiceMock.getProjectVersions(anyString()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例11: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
// Prepare site.
when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");
PowerMockito.mockStatic(Site.class);
Mockito.when(Site.get(any())).thenReturn(siteMock);
when(siteMock.getService()).thenReturn(jiraServiceMock);
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Object> builder = ResponseData.builder();
when(jiraServiceMock.createIssueRemoteLink(anyString(), any()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例12: retry
import hudson.model.TaskListener; //导入依赖的package包/类
private void retry(StepContext perBodyContext) {
body = null;
getContext().saveState();
try {
perBodyContext.get(TaskListener.class).getLogger().println("Will try again after " + Util.getTimeSpanString(recurrencePeriod));
} catch (Exception x) {
getContext().onFailure(x);
return;
}
task = Timer.get().schedule(new Runnable() {
@Override public void run() {
task = null;
body = getContext().newBodyInvoker().withCallback(new Callback(id)).start();
}
}, recurrencePeriod, TimeUnit.MILLISECONDS);
recurrencePeriod = Math.min((long)(recurrencePeriod * RECURRENCE_PERIOD_BACKOFF), MAX_RECURRENCE_PERIOD);
}
示例13: getVirtEnvName
import hudson.model.TaskListener; //导入依赖的package包/类
/**
* Private method to get the name of the virtual environment
* given in virtualenv tag of warhorn config file
*
* @param build Build
* @param workspace Jenkins job workspace
* @param listener Task listener
* @return virtEnvName Name of the Virtual Environment
* @throws ParserConfigurationException ParserConfigurationException
* @throws SAXException SAXException
* @throws IOException IOException
*/
private String getVirtEnvName(Run<?,?> build, FilePath workspace, TaskListener listener)
throws ParserConfigurationException, SAXException, IOException{
String absWarhornConfig = "";
if (configType.equals("configGit")){
absWarhornConfig = workspace.getRemote() + "/configRepo/" + gitConfigFile;
} else {
absWarhornConfig = workspace.getRemote() + "/warhorn_config.xml";
}
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new File(absWarhornConfig));
NodeList veNodeList = document.getElementsByTagName("virtualenv");
String virtEnvName = "";
if(veNodeList.getLength() > 0){
Element element = (Element) veNodeList.item(0);
virtEnvName = element.getAttribute("name");
}
return virtEnvName;
}
示例14: setup
import hudson.model.TaskListener; //导入依赖的package包/类
@Before
public void setup() throws IOException, InterruptedException {
// Prepare site.
when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");
PowerMockito.mockStatic(Site.class);
Mockito.when(Site.get(any())).thenReturn(siteMock);
when(siteMock.getService()).thenReturn(jiraServiceMock);
when(runMock.getCauses()).thenReturn(null);
when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
doNothing().when(printStreamMock).println();
final ResponseDataBuilder<Object> builder = ResponseData.builder();
when(jiraServiceMock.getIssueLink(anyString()))
.thenReturn(builder.successful(true).code(200).message("Success").build());
when(contextMock.get(Run.class)).thenReturn(runMock);
when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
示例15: retrieveMergeRequest
import hudson.model.TaskListener; //导入依赖的package包/类
private void retrieveMergeRequest(SCMSourceCriteria criteria, @Nonnull SCMHeadObserver observer, @Nonnull GitLabSCMMergeRequestEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
MergeRequestObjectAttributes attributes = event.getPayload().getObjectAttributes();
String targetBranch = attributes.getTargetBranch();
if (!source.isExcluded(targetBranch)) {
int mrId = attributes.getId();
log(listener, Messages.GitLabSCMSource_retrievingMergeRequest(mrId));
try {
GitLabMergeRequest mr = api().getMergeRequest(source.getProjectId(), mrId);
observe(criteria, observer, mr, listener);
} catch (NoSuchElementException e) {
log(listener, Messages.GitLabSCMSource_removedMergeRequest(mrId));
branchesWithMergeRequests(listener).remove(mrId);
}
int sourceProjectId = attributes.getSourceProjectId();
if (sourceProjectId == source.getProjectId()) {
observe(criteria, observer, createBranch(source.getProjectId(), attributes.getSourceBranch(), attributes.getLastCommit().getId()), listener);
}
}
}