當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。