Ejemplo n.º 1
0
 @Test
 public void testGetChangesContainIssues() throws Exception {
   Job job = getJob();
   Build jobBuild = job.getBuild("lastCompletedBuild");
   ChangeSet buildChanges =
       client.getJobChanges(JenkinsClient.urlEncode(JENKINS_JOB), jobBuild.number);
   assertNotNull(buildChanges);
   for (ChangeSetItem changeItem : buildChanges.items) {
     assertNotNull(changeItem.issue);
   }
 }
Ejemplo n.º 2
0
  private Build buildJob(String jobPath)
      throws Exception, UnsupportedEncodingException, InterruptedException {
    Job job = null;
    AbstractNode result = client.execute(config.getUrl() + "/job/" + jobPath + "/build?delay=0sec");
    assertTrue(result instanceof ResetNode);
    for (int retryCount = 0;
        !(job = client.getJob(jobPath)).isBuilding() && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    return job.builds.get(0);
  }
Ejemplo n.º 3
0
  private Job getJobNotBuilding() throws Exception {
    Job job = null;
    for (int retryCount = 0;
        (job = client.getJob(JenkinsClient.urlEncode(JENKINS_JOB))).isBuilding()
            && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    if (job.isBuilding()) {
      throw new Exception("No jobs found in Jenkins Server");
    }

    return job;
  }
Ejemplo n.º 4
0
  @Test
  public void testCanStopBuild() throws Exception {
    Job job = getJobNotBuilding();
    Build build = buildJob(job.path);
    AbstractNode result =
        client.execute(config.getUrl() + "/job/" + job.path + "/" + build.number + "/stop");
    assertTrue(result instanceof ResetNode);
    for (int retryCount = 0;
        (job = client.getJob(job.path)).isBuilding() && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    assertEquals("aborted", job.builds.get(0).result.toLowerCase());
  }
Ejemplo n.º 5
0
 @Test
 public void testGetNotNullViewList() throws Exception {
   ViewList viewList = client.getViewList();
   assertNotNull(viewList);
   assertNotNull(viewList.getViews());
   assertNotNull(viewList.getPrimaryView());
 }
Ejemplo n.º 6
0
 private Build buildJob() throws UnsupportedEncodingException, InterruptedException, Exception {
   return buildJob(JenkinsClient.urlEncode(JENKINS_JOB));
 }
Ejemplo n.º 7
0
 @Test
 public void testCanTriggerBuildSuccessfully() throws Exception {
   JobName job = getJobNotBuilding();
   buildJob(job.path);
   assertTrue(client.getJob(job.path).isBuilding());
 }
Ejemplo n.º 8
0
 @Test
 public void testGetNotNullQueue() throws Exception {
   Queue queue = client.getQueue();
   assertNotNull(queue);
 }
Ejemplo n.º 9
0
 @Test
 public void testGetNotNullComputerList() throws Exception {
   ComputerList computerList = client.getComputerList();
   assertNotNull(computerList);
 }
Ejemplo n.º 10
0
 @Test
 public void testGetJobPath() throws Exception {
   Job job = getJob();
   assertNotNull(job);
   assertEquals(JenkinsClient.urlEncode(JENKINS_JOB), job.path);
 }
Ejemplo n.º 11
0
 private Job getJob() throws Exception {
   Job job = client.getJob(JenkinsClient.urlEncode(JENKINS_JOB));
   return job;
 }