Java 类hudson.model.TaskListener 实例源码

项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
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;
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * 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");
    }
}
项目:hubot-steps-plugin    文件:SendStepTest.java   
@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);
}
项目:gitea-plugin    文件:GiteaSCMSource.java   
@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;
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * 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);
    }
}
项目:jira-steps-plugin    文件:AddWatcherStepTest.java   
@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);

}
项目:Jenkins-Plugin-Examples    文件:CatchErrorStep.java   
@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);
    }
}
项目:jira-steps-plugin    文件:LinkIssuesStepTest.java   
@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);
}
项目:jira-steps-plugin    文件:GetIssueStepTest.java   
@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);
}
项目:jira-steps-plugin    文件:GetProjectVersionsStepTest.java   
@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);
}
项目:jira-steps-plugin    文件:NewIssueRemoteLinkStepTest.java   
@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);
}
项目:Jenkins-Plugin-Examples    文件:WaitForConditionStep.java   
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);
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * 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;
}
项目:jira-steps-plugin    文件:GetIssueLinkStepTest.java   
@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);
}
项目:gitlab-branch-source-plugin    文件:SourceHeads.java   
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);
        }
    }
}
项目:jira-steps-plugin    文件:AssignIssueStepTest.java   
@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.assignIssue(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);
}
项目:jira-steps-plugin    文件:DeleteIssueRemoteLinkStepTest.java   
@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.deleteIssueRemoteLink(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);
}
项目:jira-steps-plugin    文件:GetComponentIssueCountStepTest.java   
@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.getComponentIssueCount(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);
}
项目:jira-steps-plugin    文件:GetCommentsStepTest.java   
@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.getComments(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);
}
项目:jira-steps-plugin    文件:GetProjectComponentsStepTest.java   
@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.getProjectComponents(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);
}
项目:jira-steps-plugin    文件:GetProjectsStepTest.java   
@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.getProjects())
      .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);
}
项目:jira-steps-plugin    文件:EditCommentStepTest.java   
@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.updateComment(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);
}
项目:jira-steps-plugin    文件:NotifyIssueStepTest.java   
@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.notifyIssue(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);
}
项目:jira-steps-plugin    文件:DeleteIssueRemoteLinksStepTest.java   
@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.deleteIssueRemoteLinks(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);
}
项目:jira-steps-plugin    文件:EditIssueStepTest.java   
@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.updateIssue(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);
}
项目:jira-steps-plugin    文件:DeleteIssueLinkStepTest.java   
@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.deleteIssueLink(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);
}
项目:jira-steps-plugin    文件:GetProjectStepTest.java   
@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.getProject(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);
}
项目:jira-steps-plugin    文件:TransitionIssueStepTest.java   
@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.transitionIssue(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);
}
项目:jira-steps-plugin    文件:EditComponentStepTest.java   
@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.updateComponent(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);
}
项目:jira-steps-plugin    文件:NewVersionStepTest.java   
@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.createVersion(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);
}
项目:hubot-steps-plugin    文件:ApproveStepTest.java   
@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);

}
项目:jira-steps-plugin    文件:NewComponentStepTest.java   
@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.createComponent(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);
}
项目:jira-steps-plugin    文件:GetIssueTransitionsStepTest.java   
@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.getIssueTransitions(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);
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
private ArrayList<CodeSceneBuildActionEntry> runDeltaAnalysesOnIndividualCommits(Configuration config, List<String> revisions, TaskListener listener) throws MalformedURLException {
    List<Commits> commitSets = revisionsAsIndividualCommitSets(revisions);
    ArrayList<CodeSceneBuildActionEntry> entries = new ArrayList<>(commitSets.size());

    if (!commitSets.isEmpty()) {
        listener.getLogger().format("Starting delta analysis on %d commit(s)...%n", commitSets.size());
        for (Commits commits : commitSets) {
            DeltaAnalysis deltaAnalysis = new DeltaAnalysis(config);
            listener.getLogger().format("Running delta analysis on commits (%s) in repository %s.%n", commits.value(), config.gitRepisitoryToAnalyze().value());
            DeltaAnalysisResult result = deltaAnalysis.runOn(commits);

            URL detailsUrl = new URL(
                    config.codeSceneUrl().getProtocol(),
                    config.codeSceneUrl().getHost(),
                    config.codeSceneUrl().getPort(),
                    result.getViewUrl());

            entries.add(new CodeSceneBuildActionEntry(
                    commits.value().get(0).value(),
                    false,
                    commits.value(),
                    result.getRisk(),
                    result.getWarnings().value(),
                    detailsUrl,
                    riskThreshold));
        }
    } else {
        listener.getLogger().format("No commits to run delta analysis on.%n");
    }

    return entries;
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
public FileUploadCallable(WarriorPluginBuilder obj, File uploadFolder, File uploadFile, TaskListener listener){
    this.uploadType = obj.uploadServerType;
    this.ipAddr = obj.uploadServerIp;
    this.username = obj.uploadServerUname;
    this.password = obj.uploadServerPwd;
    this.destDir = obj.uploadServerDir;
    this.uploadFolder = uploadFolder;
    this.uploadFile = uploadFile;
    this.listener = listener;
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
private void markAsUnstableWhenAtRiskThreshold(int threshold, CodeSceneBuildActionEntry entry, Run<?, ?> build, TaskListener listener) throws IOException {
    if (isMarkBuildAsUnstable() && entry.getHitsRiskThreshold()) {
        String link = HyperlinkNote.encodeTo(entry.getViewUrl().toExternalForm(), String.format("Delta analysis result with risk %d", entry.getRisk().getValue()));
        listener.error("%s hits the risk threshold (%d). Marking build as unstable.", link, threshold);
        Result newResult = Result.UNSTABLE;

        Result result = build.getResult();
        if (result != null) {
            build.setResult(result.combine(newResult));
        } else {
            build.setResult(newResult);
        }
    }
}
项目:custom-notifier-plugin    文件:JdumpNotifier.java   
public JdumpService newJdumpService(AbstractBuild build, TaskListener listener) {
    return new JdumpServiceImpl(alarmWay,
                                alarmUserEmails,
                                alarmUserPhones,
                                alarmUserErps,
                                testResultFile,
                                onStart,
                                onSuccess,
                                onFailed,
                                listener,
                                build);
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * Private method to get the values given in warriorframework
 * tag of warhorn config file
 *
 * @param build Build
 * @param workspace Jenkins job workspace
 * @param listener Task listener
 * @return cloneDetails Details required to clone warriorframework
 * @throws ParserConfigurationException ParserConfigurationException
 * @throws SAXException SAXException
 * @throws IOException IOException
 */
private String[] getWfCloneDetails(Run<?,?> build, FilePath workspace, TaskListener listener)
        throws ParserConfigurationException, SAXException, IOException{

    String absWarhornConfig = "";
    String[] cloneDetails = new String[4];
    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 wfNodeList = document.getElementsByTagName("warriorframework");
    String url = "";
    String branch = "";
    if(wfNodeList.getLength() > 0){
        Element element = (Element) wfNodeList.item(0);
        url = element.getAttribute("url");
        branch = element.getAttribute("label");
    }
    if (url.isEmpty()){
        url = "https://github.com/warriorframework/warriorframework.git";
    }
    if (branch.isEmpty()){
        branch = "origin/develop";
    }

    // Temp_fix: Using the username & password given for cloning warhorn config file.
    // These will be empty/default if not provided for warhorn config file
    cloneDetails[0] = this.gitConfigUname;
    cloneDetails[1] = this.gitConfigPwd;
    cloneDetails[2] = url;
    cloneDetails[3] = branch;

    return cloneDetails;
}
项目:gitea-plugin    文件:GiteaNotifier.java   
@Override
public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener, File changelogFile,
                       SCMRevisionState pollingBaseline) throws Exception {
    try {
        sendNotifications(build, listener);
    } catch (IOException | InterruptedException e) {
        e.printStackTrace(listener.error("Could not send notifications"));
    }
}
项目:gitea-plugin    文件:GiteaNotifier.java   
/**
 * {@inheritDoc}
 */
@Override
public void onStarted(Run<?, ?> run, TaskListener listener) {
    try {
        sendNotifications(run, listener);
    } catch (IOException | InterruptedException e) {
        e.printStackTrace(listener.error("Could not send notifications"));
    }
}