本文整理汇总了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;
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例15: getListener
import hudson.util.LogTaskListener; //导入依赖的package包/类
@NonNull
@Override
public TaskListener getListener() {
return new LogTaskListener(Logger.getAnonymousLogger(), Level.INFO);
}