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


Java LogTaskListener类代码示例

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


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

示例1: buildVar

import hudson.util.LogTaskListener; //导入依赖的package包/类
public static String buildVar(final AbstractBuild<?, ?> build, final String toResolve) {
    if (toResolve == null)
        return null;
    
    if (build == null) // is null when called from config page to test connection
        return toResolve;
    
    VariableResolver<String> vr = build.getBuildVariableResolver();
    String resolved = Util.replaceMacro(toResolve, vr);
    try {
        EnvVars env = build.getEnvironment(new LogTaskListener(LOG, Level.INFO));
        resolved = env.expand(resolved);
    } catch (Exception e) {
        //TODO no-op?
    }
    return resolved;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:18,代码来源:Resolver.java

示例2: getExpandedCustomMessage

import hudson.util.LogTaskListener; //导入依赖的package包/类
String getExpandedCustomMessage(AbstractBuild build) {
	String result = "";
	if(notifier.includeCustomMessage()) {
		String customMessage = notifier.getCustomMessage();
		EnvVars envVars = new EnvVars();
		try {
			envVars = build.getEnvironment(new LogTaskListener(logger, INFO));
		} catch (IOException | InterruptedException e) {
			logger.log(SEVERE, e.getMessage(), e);
		}
		result = envVars.expand(customMessage);
	}
	return result;
}
 
开发者ID:jovandeginste,项目名称:jenkins-mattermost-plugin,代码行数:15,代码来源:ActiveNotifier.java

示例3: testPerform

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Test
public void testPerform() throws IOException, ExecutionException, InterruptedException {
    List<JsonParameterVariables> jsonParameterVariables = new ArrayList<>();
    jsonParameterVariables.add(new JsonParameterVariables("KEY", "$.key2"));
    LambdaInvokeVariables clone = new LambdaInvokeVariables(false, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "function", "payload", true, true, jsonParameterVariables);
    LambdaInvokeVariables spy = Mockito.spy(clone);

    when(original.getClone()).thenReturn(spy);
    when(spy.getLambdaClientConfig()).thenReturn(clientConfig);
    when(clientConfig.getClient()).thenReturn(lambdaClient);
    final String logBase64 = "bGFtYmRh";
    final String responsePayload = "{\"key2\": \"value2\"}";

    InvokeResult invokeResult = new InvokeResult()
            .withLogResult(logBase64)
            .withPayload(ByteBuffer.wrap(responsePayload.getBytes()));

    when(lambdaClient.invoke(any(InvokeRequest.class)))
            .thenReturn(invokeResult);

    FreeStyleProject p = j.createFreeStyleProject();
    p.getPublishersList().add(new LambdaInvokePublisher(Arrays.asList(original, original)));
    FreeStyleBuild build = p.scheduleBuild2(0).get();
    EnvVars environment = build.getEnvironment(new LogTaskListener(LOGGER, Level.INFO));

    assertEquals("value2", environment.get("KEY"));
    assertEquals(Result.SUCCESS, build.getResult());
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:29,代码来源:LambdaInvokePublisherTest.java

示例4: testPerformInstanceRole

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Test
public void testPerformInstanceRole() throws IOException, ExecutionException, InterruptedException {
    List<JsonParameterVariables> jsonParameterVariables = new ArrayList<>();
    jsonParameterVariables.add(new JsonParameterVariables("KEY", "$.key2"));
    LambdaInvokeVariables clone = new LambdaInvokeVariables(true, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "function", "payload", true, true, jsonParameterVariables);
    LambdaInvokeVariables spy = Mockito.spy(clone);

    when(original.getClone()).thenReturn(spy);
    when(spy.getLambdaClientConfig()).thenReturn(clientConfig);
    when(clientConfig.getClient()).thenReturn(lambdaClient);
    final String logBase64 = "bGFtYmRh";
    final String responsePayload = "{\"key2\": \"value2\"}";

    InvokeResult invokeResult = new InvokeResult()
            .withLogResult(logBase64)
            .withPayload(ByteBuffer.wrap(responsePayload.getBytes()));

    when(lambdaClient.invoke(any(InvokeRequest.class)))
            .thenReturn(invokeResult);

    FreeStyleProject p = j.createFreeStyleProject();
    p.getPublishersList().add(new LambdaInvokePublisher(Arrays.asList(original, original)));
    FreeStyleBuild build = p.scheduleBuild2(0).get();
    EnvVars environment = build.getEnvironment(new LogTaskListener(LOGGER, Level.INFO));

    assertEquals("value2", environment.get("KEY"));
    assertEquals(Result.SUCCESS, build.getResult());
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:29,代码来源:LambdaInvokePublisherTest.java

示例5: testPerform

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Test
public void testPerform() throws IOException, ExecutionException, InterruptedException {
    List<JsonParameterVariables> jsonParameterVariables = new ArrayList<JsonParameterVariables>();
    jsonParameterVariables.add(new JsonParameterVariables("KEY", "$.key2"));
    LambdaInvokeBuildStepVariables clone = new LambdaInvokeBuildStepVariables(false, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "function", "payload", true, jsonParameterVariables);
    LambdaInvokeBuildStepVariables spy = Mockito.spy(clone);

    when(original.getClone()).thenReturn(spy);
    when(spy.getLambdaClientConfig()).thenReturn(clientConfig);
    when(clientConfig.getClient()).thenReturn(lambdaClient);
    final String logBase64 = "bGFtYmRh";
    final String responsePayload = "{\"key2\": \"value2\"}";

    InvokeResult invokeResult = new InvokeResult()
            .withLogResult(logBase64)
            .withPayload(ByteBuffer.wrap(responsePayload.getBytes()));

    when(lambdaClient.invoke(any(InvokeRequest.class)))
            .thenReturn(invokeResult);

    FreeStyleProject p = j.createFreeStyleProject();
    p.getBuildersList().add(new LambdaInvokeBuildStep(original));
    FreeStyleBuild build = p.scheduleBuild2(0).get();
    EnvVars environment = build.getEnvironment(new LogTaskListener(LOGGER, Level.INFO));

    assertEquals("value2", environment.get("KEY"));
    assertEquals(Result.SUCCESS, build.getResult());
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:29,代码来源:LambdaInvokeBuildStepTest.java

示例6: testPerformFailure

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Test
public void testPerformFailure() throws IOException, ExecutionException, InterruptedException {
    List<JsonParameterVariables> jsonParameterVariables = new ArrayList<JsonParameterVariables>();
    jsonParameterVariables.add(new JsonParameterVariables("KEY", "$.key2"));
    LambdaInvokeBuildStepVariables clone = new LambdaInvokeBuildStepVariables(false, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "function", "payload", true, jsonParameterVariables);
    LambdaInvokeBuildStepVariables spy = Mockito.spy(clone);

    when(original.getClone()).thenReturn(spy);
    when(spy.getLambdaClientConfig()).thenReturn(clientConfig);
    when(clientConfig.getClient()).thenReturn(lambdaClient);
    final String logBase64 = "bGFtYmRh";
    final String responsePayload = "{\"errorMessage\":\"event_fail\"}";

    InvokeResult invokeResult = new InvokeResult()
            .withLogResult(logBase64)
            .withPayload(ByteBuffer.wrap(responsePayload.getBytes()))
            .withFunctionError("Unhandled");

    when(lambdaClient.invoke(any(InvokeRequest.class)))
            .thenReturn(invokeResult);

    FreeStyleProject p = j.createFreeStyleProject();
    p.getBuildersList().add(new LambdaInvokeBuildStep(original));
    FreeStyleBuild build = p.scheduleBuild2(0).get();
    EnvVars environment = build.getEnvironment(new LogTaskListener(LOGGER, Level.INFO));

    assertEquals(null, environment.get("KEY"));
    assertEquals(Result.FAILURE, build.getResult());
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:30,代码来源:LambdaInvokeBuildStepTest.java

示例7: setUp

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    if (!privateKeyFile.exists()) return;

    repository = tempDirAllocator.allocate();
    Logger logger = Logger.getLogger(this.getClass().getPackage().getName());
    logger.setLevel(Level.ALL);
    listener = new hudson.util.LogTaskListener(logger, Level.ALL);
    setupClient = Git.with(listener, new hudson.EnvVars()).in(repository).getClient();
    setupClient.addDefaultCredentials((BasicSSHUserPrivateKey) createPrivateKeyCredentials(credentialsId, privateKeyFile));
    prepareRepository();
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:13,代码来源:CredentialsTest.java

示例8: getClientHelper

import hudson.util.LogTaskListener; //导入依赖的package包/类
private ClientHelper getClientHelper(DescriptorImpl p4scm) throws Exception {

		LogTaskListener listener = new LogTaskListener(logger, Level.INFO);

		String credential = p4scm.getCredential();
		String clientName = p4scm.getClientName();
		String depotPath = p4scm.getDepotPath();
		depotPath = depotPath.endsWith("/") ? depotPath : depotPath + "/";

		Jenkins j = Jenkins.getInstance();
		if (j == null) {
			return null;
		}
		
		String rootPath = j.getRootDir().getCanonicalPath();

		StringBuffer view = new StringBuffer();
		view.append(depotPath + "...");
		view.append(" ");
		view.append("//" + clientName + "/...");

		WorkspaceSpec spec = new WorkspaceSpec(true, true, false, false, false, false, "", "LOCAL", view.toString(), null, null, null, true);

		ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("utf8", false, clientName, spec);
		workspace.setExpand(new HashMap<String, String>());
		workspace.setRootPath(rootPath);

		ClientHelper p4 = new ClientHelper(Jenkins.getActiveInstance(), credential, listener, clientName, "utf8");
		p4.setClient(workspace);

		return p4;
	}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:33,代码来源:ConfigurationListener.java

示例9: P4SCMFileSystem

import hudson.util.LogTaskListener; //导入依赖的package包/类
protected P4SCMFileSystem(@NonNull Item owner, @NonNull PerforceScm scm, @CheckForNull P4Revision rev) throws Exception {
	super(rev);
	String credential = scm.getCredential();
	LogTaskListener listener = new LogTaskListener(LOGGER, Level.ALL);
	Workspace workspace = scm.getWorkspace();
	this.p4 = new TempClientHelper(owner, credential, listener, workspace);
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:8,代码来源:P4SCMFileSystem.java

示例10: ConnectionHelper

import hudson.util.LogTaskListener; //导入依赖的package包/类
public ConnectionHelper(P4BaseCredentials credential) {
	this.listener = new LogTaskListener(logger, Level.INFO);
	this.p4credential = credential;
	this.connectionConfig = new ConnectionConfig(credential);
	this.authorisationConfig = new AuthorisationConfig(credential);
	connectionRetry();
	validate = new Validate(listener);
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:9,代码来源:ConnectionHelper.java

示例11: testPollingPin

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Test
public void testPollingPin() throws Exception {

	String client = "manual.ws";
	String stream = null;
	String line = "LOCAL";
	String view = "//depot/... //" + client + "/...";
	WorkspaceSpec spec = new WorkspaceSpec(false, false, false, false, false, false, stream, line, view);

	FreeStyleProject project = jenkins.createFreeStyleProject("PollingPin");
	ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", false, client, spec);

	// Pin at label auto15
	Populate populate = new AutoCleanImpl(true, true, false, false, "auto15", null);
	PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
	project.setScm(scm);
	project.save();

	// Build at change 3
	List<ParameterValue> list = new ArrayList<ParameterValue>();
	list.add(new StringParameterValue(ReviewProp.STATUS.toString(), "submitted"));
	list.add(new StringParameterValue(ReviewProp.CHANGE.toString(), "3"));
	Action actions = new SafeParametersAction(new ArrayList<ParameterValue>(), list);

	FreeStyleBuild build;
	Cause.UserIdCause cause = new Cause.UserIdCause();
	build = project.scheduleBuild2(0, cause, actions).get();
	assertEquals(Result.SUCCESS, build.getResult());

	// Poll for changes
	LogTaskListener listener = new LogTaskListener(logger, Level.INFO);
	project.poll(listener);
	List<P4Ref> buildList = scm.getIncrementalChanges();
	assertEquals(12, buildList.size());
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:36,代码来源:PollingTest.java

示例12: testPollingPin

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Test
public void testPollingPin() throws Exception {

	String client = "graph.ws";
	String stream = null;
	String line = "LOCAL";
	String view = "//depot/jam/... //" + client + "/jam/...\n";
	view += "//graph/scm-api-plugin/... //" + client + "/scm-api/...\n";
	WorkspaceSpec spec = new WorkspaceSpec(false, false, false, false, false, false, stream, line, view);

	FreeStyleProject project = jenkins.createFreeStyleProject("FreeGraphPolling");
	ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", false, client, spec);

	Populate populate = new GraphHybridImpl(false, null, null);
	PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
	project.setScm(scm);
	project.save();

	Action actions = new SafeParametersAction(new ArrayList<ParameterValue>(), new ArrayList<ParameterValue>());

	// Build at latest
	FreeStyleBuild build;
	Cause.UserIdCause cause = new Cause.UserIdCause();
	build = project.scheduleBuild2(0, cause, actions).get();
	assertEquals(Result.SUCCESS, build.getResult());

	// Submit graph add
	commitFile(jenkins, "//graph/scm-api-plugin/test.add", "Content");

	// Poll for changes
	LogTaskListener listener = new LogTaskListener(logger, Level.INFO);
	project.poll(listener);
	List<P4Ref> buildList = scm.getIncrementalChanges();
	assertEquals(1, buildList.size());

	P4Ref ref = buildList.get(0);
	assertTrue(ref instanceof P4GraphRef);
	P4GraphRef commit = (P4GraphRef) ref;
	assertEquals("//graph/scm-api-plugin.git", commit.getRepo());
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:41,代码来源:GraphTest.java

示例13: setUp

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Before
public void setUp() throws IOException, InterruptedException {
    git = null;
    repo = tempFolder.newFolder();
    /* Use a repo with a special character in name - JENKINS-43931 */
    String newDirName = "use " + specialCharacter + " dir";
    File repoParent = repo;
    repo = new File(repoParent, newDirName);
    boolean dirCreated = repo.mkdirs();
    assertTrue("Failed to create " + repo.getAbsolutePath(), dirCreated);
    File repoTemp = new File(repoParent, newDirName + "@tmp"); // use adjacent temp directory
    dirCreated = repoTemp.mkdirs();
    assertTrue("Failed to create " + repoTemp.getAbsolutePath(), dirCreated);
    Logger logger = Logger.getLogger(this.getClass().getPackage().getName() + "-" + logCount++);
    handler = new LogHandler();
    handler.setLevel(Level.ALL);
    logger.setUseParentHandlers(false);
    logger.addHandler(handler);
    logger.setLevel(Level.ALL);
    listener = new hudson.util.LogTaskListener(logger, Level.ALL);
    listener.getLogger().println(LOGGING_STARTED);
    git = Git.with(listener, new hudson.EnvVars()).in(repo).using(gitImpl).getClient();
    if (gitImpl.equals("git")) {
        addExpectedLogSubstring("> git fetch ");
        addExpectedLogSubstring("> git checkout -b master ");
    }
    addExpectedLogSubstring("Using reference repository: ");

    assertTrue("Bad username, password, privateKey combo: '" + username + "', '" + password + "'",
            (password == null || password.isEmpty()) ^ (privateKey == null || !privateKey.exists()));
    if (password != null && !password.isEmpty()) {
        testedCredential = newUsernamePasswordCredential(username, password);
    }
    if (privateKey != null && privateKey.exists()) {
        testedCredential = newPrivateKeyCredential(username, privateKey);
    }
    assertThat(testedCredential, notNullValue());
    Fingerprint fingerprint = CredentialsProvider.getFingerprintOf(testedCredential);
    assertThat("Fingerprint should not be set", fingerprint, nullValue());
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:41,代码来源:CredentialsTest.java

示例14: createLogger

import hudson.util.LogTaskListener; //导入依赖的package包/类
@Before
public void createLogger() {
    Logger logger = Logger.getLogger(this.getClass().getPackage().getName() + "-" + logCount++);
    handler = new LogHandler();
    handler.setLevel(Level.ALL);
    logger.setUseParentHandlers(false);
    logger.addHandler(handler);
    logger.setLevel(Level.ALL);
    listener = new hudson.util.LogTaskListener(logger, Level.ALL);
    listener.getLogger().println(LOGGING_STARTED);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:12,代码来源:WarnTempDirValueTest.java

示例15: getListener

import hudson.util.LogTaskListener; //导入依赖的package包/类
@NonNull
@Override
public TaskListener getListener() {
    return new LogTaskListener(Logger.getAnonymousLogger(), Level.INFO);
}
 
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:6,代码来源:ASFGitSCMNavigatorTest.java


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