• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Job类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.offbytwo.jenkins.model.Job的典型用法代码示例。如果您正苦于以下问题:Java Job类的具体用法?Java Job怎么用?Java Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Job类属于com.offbytwo.jenkins.model包,在下文中一共展示了Job类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Before
public void init() throws Exception {
    String jenkinsUri = System.getProperty("gretltest_jenkins_uri");
    System.out.println("jenkinsUri: " + jenkinsUri);
    // TODO uri must start with http
    String jenkinsUser = System.getProperty("gretltest_jenkins_user");
    System.out.println("jenkinsUser: " + jenkinsUser);


    try {
        jenkins = new JenkinsServer(new URI(jenkinsUri), jenkinsUser, System.getProperty("gretltest_jenkins_pwd"));
        //jenkins = new JenkinsServer(new URI("http://localhost:8080"), "admin", "admin1234");
        Map<String, Job> jobs = jenkins.getJobs();
        System.out.println(jobs.size() + " jobs: ");
        for (String jobName: jobs.keySet()) {
            System.out.println(jobName);
        }
    } catch (Exception e) {
        System.err.println("=================================================");
        System.err.println("Make sure that Jenkins is running and accessible.");
        System.err.println("Start with Docker: docker/start-jenkins.sh");
        System.err.println("=================================================");
        throw e;
    }
}
 
开发者ID:sogis,项目名称:gretl,代码行数:26,代码来源:JenkinsTest.java


示例2: main

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("Usage: jobName [jenkinsServerUrl]");
        return;
    }
    String job = args[0];
    String jenkinsUrl = "http://jenkins.vagrant.f8/";
    if (args.length > 1) {
        jenkinsUrl = args[1];
    }

    try {
        JenkinsServer jenkins = JenkinsAsserts.createJenkinsServer(jenkinsUrl);

        Map<String, Job> jobs = jenkins.getJobs();
        Set<Map.Entry<String, Job>> entries = jobs.entrySet();
        for (Map.Entry<String, Job> entry : entries) {
            System.out.println("Job " + entry.getKey() + " = " + entry.getValue());
        }

        JenkinsAsserts.assertJobLastBuildIsSuccessful(jenkins, job);
    } catch (Exception e) {
        SeleniumTests.logError(e.getMessage(), e);
    }

}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:27,代码来源:JenkinsTestMain.java


示例3: testCreateJob

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void testCreateJob() throws Exception {
    final String sourceJob = "pr";
    final String jobName = "test-job-" + UUID.randomUUID().toString();

    String sourceXml = server.getJobXml(sourceJob);

    server.createJob(jobName, sourceXml);

    Map<String, Job> jobs = server.getJobs();
    assertTrue(jobs.containsKey(jobName));
    JobWithDetails thisJob = jobs.get(jobName).details();
    assertNotNull(thisJob);
    assertTrue(thisJob.getBuilds().size() == 0);
    thisJob.build(ImmutableMap.of("foo_param", "MUST_PROVIDE_VALUES_DEFAULTS_DONT_WORK"));

    // wait to see if the job finishes, but with a timeout
    Future<Void> future = executor.submit(new PerformPollingTest(server, jobName));

    // If this times out, either jenkins is slow or our test failed!
    // IME, usually takes about 10-15 seconds
    future.get(30, TimeUnit.SECONDS);

    Build b = server.getJobs().get(jobName).details().getLastSuccessfulBuild();
    assertTrue(b != null);
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:27,代码来源:JenkinsServerIntegration.java


示例4: createJob

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
public void createJob(String test, JSONObject repository) throws Exception {
    String jobName = ConfigParser.parseConfigString(repository.getString("jobName"), test);

    String jobXML = generateJobXML(test, repository);
    Map<String, Job> jobs = jenkins.getJobs();
    if (jobs.containsKey(jobName.toLowerCase())) {
        jenkins.updateJob(jobName.toLowerCase(), jobXML, crumbsFlag);
        System.out.println("Updating [" + test + "]");
    }
    else {
        jenkins.createJob(jobName, jobXML, crumbsFlag);
        System.out.println("Creating [" + test + "]");
    }
    if (repository.has("addToView")) {
        String addToView = repository.getString("addToView");
        addJobToView(jobName, addToView);
    }
}
 
开发者ID:alianza-dev,项目名称:jenkins-test-job-generator,代码行数:19,代码来源:JenkinsHelper.java


示例5: call

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Override
public Void call() throws Exception {
    RepositoryConfiguration rc = cpm
        .getRepositoryConfigurationForRepository(r);
    // may someday require repo also...
    JenkinsServerConfiguration jsc = cpm
        .getJenkinsServerConfiguration(rc.getJenkinsServerName());

    if (!rc.getCiEnabled())
        return null;

    // make sure jobs exist
    List<JobTemplate> templates = jtm.getJenkinsJobsForRepository(rc);
    JenkinsServer js = jcm.getJenkinsServer(jsc, rc);
    Map<String, Job> jobs = js.getJobs();

    for (JobTemplate template : templates) {
        if (!jobs.containsKey(template.getBuildNameFor(r))) {
            log.info("Creating " + template.getName()
                + " job for repo " + r.toString());
            createJob(r, template);
        }
    }
    return null;
}
 
开发者ID:palantir,项目名称:stashbot,代码行数:26,代码来源:JenkinsManager.java


示例6: testUpdateJob

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void testUpdateJob() throws Exception {

    String jobName = "somename_verification";

    Job existingJob = Mockito.mock(Job.class);
    Map<String, Job> jobMap = new HashMap<String, Job>();
    jobMap.put(jobName, existingJob);
    Mockito.when(jenkinsServer.getJobs()).thenReturn(jobMap);

    JobTemplate jt = jtm.getDefaultVerifyJob();

    jenkinsManager.updateJob(repo, jt);

    ArgumentCaptor<String> xmlCaptor = ArgumentCaptor
        .forClass(String.class);

    Mockito.verify(xmlFormatter).generateJobXml(jt, repo);
    Mockito.verify(jenkinsServer).updateJob(Mockito.anyString(),
        xmlCaptor.capture());
    Mockito.verify(jenkinsServer, Mockito.never()).createJob(
        Mockito.anyString(), Mockito.anyString());

    Assert.assertEquals(XML_STRING, xmlCaptor.getValue());
}
 
开发者ID:palantir,项目名称:stashbot,代码行数:26,代码来源:JenkinsManagerTest.java


示例7: test01cleanup

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
/**
 * Delete all jobs that are not in administration folder.
 */
@Test
public void test01cleanup() throws IOException {
    // when
    Map<String, Job> jobs = jenkins.getJobs();
    for (String jobName: jobs.keySet()) {
        if (!"administration".equals(jobName)) {
            jenkins.deleteJob(jobName);
        }
    }
    jobs = jenkins.getJobs();

    // then
    assertThat(jobs.size(), is(1));
}
 
开发者ID:sogis,项目名称:gretl,代码行数:18,代码来源:JenkinsTest.java


示例8: test02checkThatAdminJobExists

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void test02checkThatAdminJobExists() throws IOException {
    // when
    Job job = jenkins.getJobs().get("administration");

    // then
    Optional<FolderJob> admF = jenkins.getFolderJob(job);
    assertThat(admF.isPresent(), is(true));
    FolderJob admJob = admF.get();
    assertThat(admJob.getJobs().size(), is(1));
    assertThat(admJob.getJobs().containsKey("gretl-job-generator"), is(true));
}
 
开发者ID:sogis,项目名称:gretl,代码行数:13,代码来源:JenkinsTest.java


示例9: test04shouldHaveGeneratedIliValidatorJob

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void test04shouldHaveGeneratedIliValidatorJob() throws IOException {
    // when
    Job job = jenkins.getJobs().get("iliValidator");

    // then
    assertThat(job, not(nullValue()));
}
 
开发者ID:sogis,项目名称:gretl,代码行数:9,代码来源:JenkinsTest.java


示例10: getJobs

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
/**
 * Queries a Jenkins server for all existing jobs.
 *
 * @param jsc The Jenkins server for which we are querying all jobs.
 * @return A mapping from job name to Job object of all jobs on the server.
 * @throws RuntimeException if the get operation failed.
 */
public static Map<String, Job> getJobs(JenkinsServerConfiguration jsc) {
    try {
        return getJenkinsServer(jsc).getJobs();
    } catch(IOException e) {
        throw new RuntimeException("Error getting jobs from Jenkins", e);
    }
}
 
开发者ID:palantir,项目名称:gerrit-ci,代码行数:15,代码来源:JenkinsProvider.java


示例11: testTriggerBuildShort

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void testTriggerBuildShort() throws Exception {
    String HASH = "38356e8abe0e96538dd1007278ecc02c3bf3d2cb";
    String REF = "refs/heads/master";

    JobTemplate jt = jtm.getDefaultVerifyJob();

    String jobName = jt.getBuildNameFor(repo);
    Job existingJob = Mockito.mock(Job.class);
    Mockito.when(existingJob.getName()).thenReturn(jobName);
    Map<String, Job> jobMap = new HashMap<String, Job>();
    jobMap.put(jobName, existingJob);
    Mockito.when(jenkinsServer.getJobs()).thenReturn(jobMap);

    Mockito.when(jtm.getJobTemplate(JobType.VERIFY_COMMIT, rc)).thenReturn(
        jt);

    jenkinsManager.triggerBuild(repo, JobType.VERIFY_COMMIT, HASH, REF);
    jenkinsManager.destroy();

    @SuppressWarnings({ "unchecked", "rawtypes" })
    Class<Map<String, String>> forClass = (Class) Map.class;
    ArgumentCaptor<Map<String, String>> paramCaptor = ArgumentCaptor
        .forClass(forClass);

    Mockito.verify(existingJob).build(paramCaptor.capture());

    Map<String, String> paramMap = paramCaptor.getValue();
    Assert.assertTrue(paramMap.containsKey("buildHead"));
    Assert.assertTrue(paramMap.containsKey("buildRef"));
    Assert.assertTrue(paramMap.containsKey("repoId"));
    Assert.assertFalse(paramMap.containsKey("pullRequestId"));
    Assert.assertFalse(paramMap.containsKey("mergeHead"));
}
 
开发者ID:palantir,项目名称:stashbot,代码行数:35,代码来源:JenkinsManagerTest.java


示例12: testPreserveJenkinsJobConfigDisabled

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void testPreserveJenkinsJobConfigDisabled() throws IOException {

    JobTemplate jt = jtm.getDefaultVerifyJob();
    HashMap<String, Job> jobs = Maps.newHashMap();
    jobs.put(jt.getBuildNameFor(repo), new Job()); // update job logic requires the job be there already

    Mockito.when(rc.getPreserveJenkinsJobConfig()).thenReturn(false);
    Mockito.when(jenkinsServer.getJobs()).thenReturn(jobs);

    jenkinsManager.updateJob(repo, jt);

    Mockito.verify(jenkinsServer).updateJob(Mockito.anyString(), Mockito.anyString());
}
 
开发者ID:palantir,项目名称:stashbot,代码行数:15,代码来源:JenkinsManagerTest.java


示例13: testPreserveJenkinsJobConfigEnabled

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
@Test
public void testPreserveJenkinsJobConfigEnabled() throws IOException {

    JobTemplate jt = jtm.getDefaultVerifyJob();
    HashMap<String, Job> jobs = Maps.newHashMap();
    jobs.put(jt.getBuildNameFor(repo), new Job()); // update job logic requires the job be there already

    Mockito.when(rc.getPreserveJenkinsJobConfig()).thenReturn(true);
    Mockito.when(jenkinsServer.getJobs()).thenReturn(jobs);

    jenkinsManager.updateJob(repo, jt);

    Mockito.verify(jenkinsServer, Mockito.never()).updateJob(Mockito.anyString(), Mockito.anyString());
}
 
开发者ID:palantir,项目名称:stashbot,代码行数:15,代码来源:JenkinsManagerTest.java


示例14: getJobToVerify

import com.offbytwo.jenkins.model.Job; //导入依赖的package包/类
public static Job getJobToVerify()
{
	Job jobToVerify =  null;
	int jobRetries = getJobRetryCounter();
	int retries = 1;
	while(retries <= jobRetries)
	{
	try {
		VerigreenLogger.get().log(
                JenkinsVerifier.class.getName(),
                RuntimeUtils.getCurrentMethodName(),
                String.format(
                        "Attempting to retrieve job for verification...", retries));
		jobToVerify = CollectorApi.getJenkinsServer().getJob(CollectorApi.getVerificationJobName().toLowerCase());	
		if(jobToVerify != null)
		{
			VerigreenLogger.get().log(
					JenkinsVerifier.class.getName(),
					RuntimeUtils.getCurrentMethodName(),
					String.format(
							"Job for verification was retrieved successfully after [%s] retries", retries));
			break;
		}
		else
		{
			// in case the job does not exist in Jenkins (wrong job name in the config properties)
			VerigreenLogger.get().log(
					JenkinsVerifier.class.getName(),
					RuntimeUtils.getCurrentMethodName(),
					String.format(
							"Failed to retrieve job for verification. Retrying..."));
			retries++;
		}
	}
	catch (IOException e) 
	{
		// in case the job does exist, but due to network issues (communication with Jenkins), we get an IOException and
		// the method fails to retrieve the job
		VerigreenLogger.get().error(
                   JenkinsVerifier.class.getName(),
                   RuntimeUtils.getCurrentMethodName(),
                   String.format(
                           "Failed to retrieve job for verification. Retrying..."),e);
		retries++;
	}
	}
	if(jobToVerify == null)
	{
		VerigreenLogger.get().error(
                   JenkinsVerifier.class.getName(),
                   RuntimeUtils.getCurrentMethodName(),
                   String.format(
                           "Failed get job for verification after [%s] retries", retries - 1));
		CollectorApi.getVerigreenNeededLogic().sendEmailNotification("Failed get job for verification", "<span style='font-family:Metric;'>Failed get job for verification: "+CollectorApi.getVerificationJobName()+". Please contact your DevOps engineer, there might be a load on Jenkins that prevents creating new verification jobs.</span>", new String[] { VerigreenNeededLogic.properties.getProperty("email.address") }, VerigreenNeededLogic.getSignature());
	}
	return jobToVerify;
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:58,代码来源:JenkinsVerifier.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InstructionHandle类代码示例发布时间:2022-05-22
下一篇:
Java Connect类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap