当前位置: 首页>>代码示例>>Java>>正文


Java TaskListener类代码示例

本文整理汇总了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;
}
 
开发者ID:empear-analytics,项目名称:codescene-jenkins-plugin,代码行数:26,代码来源:CodeSceneBuilder.java

示例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");
    }
}
 
开发者ID:warriorframework,项目名称:warrior-jenkins-plugin,代码行数:27,代码来源:WarriorPluginBuilder.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:hubot-steps-plugin,代码行数:19,代码来源:SendStepTest.java

示例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;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:23,代码来源:GiteaSCMSource.java

示例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);
    }
}
 
开发者ID:warriorframework,项目名称:warrior-jenkins-plugin,代码行数:29,代码来源:WarriorPluginBuilder.java

示例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);

}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:25,代码来源:AddWatcherStepTest.java

示例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);
    }
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:20,代码来源:CatchErrorStep.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:24,代码来源:LinkIssuesStepTest.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:23,代码来源:GetIssueStepTest.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:24,代码来源:GetProjectVersionsStepTest.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:24,代码来源:NewIssueRemoteLinkStepTest.java

示例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);
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:18,代码来源:WaitForConditionStep.java

示例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;
}
 
开发者ID:warriorframework,项目名称:warrior-jenkins-plugin,代码行数:35,代码来源:WarriorPluginBuilder.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:jira-steps-plugin,代码行数:24,代码来源:GetIssueLinkStepTest.java

示例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);
        }
    }
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:22,代码来源:SourceHeads.java


注:本文中的hudson.model.TaskListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。