本文整理汇总了Java中hudson.model.Cause.UserIdCause方法的典型用法代码示例。如果您正苦于以下问题:Java Cause.UserIdCause方法的具体用法?Java Cause.UserIdCause怎么用?Java Cause.UserIdCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.model.Cause
的用法示例。
在下文中一共展示了Cause.UserIdCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFreeStyleProject_buildCounter
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testFreeStyleProject_buildCounter() throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject("BuildCounter");
StaticWorkspaceImpl workspace = new StaticWorkspaceImpl("none", false, defaultClient());
String pin = "testCounter";
Populate populate = new AutoCleanImpl(false, false, false, true, pin, null);
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
// Log in and create counter for test
P4PasswordImpl admin = createCredentials("admin", "Password", p4d);
ClientHelper p4 = new ClientHelper(admin, null, "manual.ws", "utf8");
IOptionsServer iserver = p4.getConnection();
CounterOptions opts = new CounterOptions();
iserver.setCounter("testCounter", "9", opts);
Cause.UserIdCause cause = new Cause.UserIdCause();
FreeStyleBuild build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
List<String> log = build.getLog(LOG_LIMIT);
assertTrue(log.contains("P4 Task: syncing files at change: 9"));
}
示例2: testFreeStyleProject_buildHead
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testFreeStyleProject_buildHead() throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject("BuildHead");
Workspace workspace = new StaticWorkspaceImpl("none", false, defaultClient());
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
FreeStyleBuild build;
UserIdCause cause = new Cause.UserIdCause();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
List<String> log = build.getLog(LOG_LIMIT);
assertTrue(log.contains("P4 Task: syncing files at change: 40"));
CredentialsDescriptor desc = auth.getDescriptor();
assertNotNull(desc);
assertEquals("Perforce Password Credential", desc.getDisplayName());
P4PasswordImpl.DescriptorImpl impl = (P4PasswordImpl.DescriptorImpl) desc;
FormValidation form = impl.doTestConnection(p4d.getRshPort(), "false", null, null, "jenkins", "jenkins", false);
assertEquals(FormValidation.Kind.OK, form.kind);
}
示例3: testTPI83
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testTPI83() throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject("TPI83");
Workspace workspace = new StaticWorkspaceImpl("none", false, defaultClient());
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
FreeStyleBuild build;
UserIdCause cause = new Cause.UserIdCause();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
String filename = "[email protected]%#$%^&().txt";
String path = build.getWorkspace() + "/" + filename;
File add = new File(path);
add.createNewFile();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例4: triggerRebuild
import hudson.model.Cause; //导入方法依赖的package包/类
@Override
public void triggerRebuild(String projectName, String buildId) {
AbstractProject project = ProjectUtil.getProject(projectName, Jenkins.getInstance());
if (!project.hasPermission(Item.BUILD)) {
throw new BadCredentialsException("Not authorized to trigger build");
}
AbstractBuild build = project.getBuildByNumber(Integer.parseInt(buildId));
@SuppressWarnings("unchecked")
List<Cause> prevCauses = build.getCauses();
List<Cause> newCauses = new ArrayList<>();
for (Cause cause : prevCauses) {
if (!(cause instanceof Cause.UserIdCause)) {
newCauses.add(cause);
}
}
newCauses.add(new Cause.UserIdCause());
CauseAction causeAction = new CauseAction(newCauses);
project.scheduleBuild2(project.getQuietPeriod(),null, causeAction, build.getAction(ParametersAction.class));
}
示例5: testPublishWithPurge
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testPublishWithPurge() throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject("Publish-purge");
// Create workspace
String client = "manual.ws";
String stream = null;
String line = "LOCAL";
String view = "//depot/Data/... //" + client + "/...";
WorkspaceSpec spec = new WorkspaceSpec(true, true, false, false, false, false, stream, line, view);
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", true, client, spec);
// Populate with P4 scm
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
// Create artifact files
project.getBuildersList().add(new CreateArtifact("artifact.1", "content"));
project.getBuildersList().add(new CreateArtifact("artifact.2", "content"));
// Submit artifacts
SubmitImpl submit = new SubmitImpl("publish", true, true, true, "3");
PublishNotifier publish = new PublishNotifier(CREDENTIAL, workspace, submit);
project.getPublishersList().add(publish);
project.save();
// Start build
Cause.UserIdCause cause = new Cause.UserIdCause();
FreeStyleBuild build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
// Stat file and check type
ClientHelper p4 = new ClientHelper(project, CREDENTIAL, null, client, "none");
List<IFileSpec> fileSpec = FileSpecBuilder.makeFileSpecList("//depot/Data/artifact.1");
GetExtendedFilesOptions opts = new GetExtendedFilesOptions();
List<IExtendedFileSpec> eSpec = p4.connection.getExtendedFiles(fileSpec, opts);
assertEquals(eSpec.get(0).getHeadType(), "text+S3");
}
示例6: testPollingPin
import hudson.model.Cause; //导入方法依赖的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());
}
示例7: testPinHost_ManualWs
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testPinHost_ManualWs() throws Exception {
String client = "manual.ws";
String stream = null;
String line = "LOCAL";
String view = "//depot/Data/... //" + client + "/...";
WorkspaceSpec spec = new WorkspaceSpec(false, false, false, false, false, false, stream, line, view);
FreeStyleProject project = jenkins.createFreeStyleProject("Manual-Head");
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", true, client, spec);
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
FreeStyleBuild build;
UserIdCause cause = new Cause.UserIdCause();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
// Log in with client for next set of tests...
ClientHelper p4 = new ClientHelper(auth, null, "manual.ws", "utf8");
IClient iclient = p4.getClient();
String clienthost = iclient.getHostName();
String hostname = InetAddress.getLocalHost().getHostName();
assertNotNull(clienthost);
assertEquals(hostname, clienthost);
}
示例8: testFreeStyleProject_TemplateWs
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testFreeStyleProject_TemplateWs() throws Exception {
String client = "test.ws";
String format = "jenkins-${node}-${project}.ws";
FreeStyleProject project = jenkins.createFreeStyleProject("Template-Head");
TemplateWorkspaceImpl workspace = new TemplateWorkspaceImpl("none", false, client, format);
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
FreeStyleBuild build;
Cause.UserIdCause cause = new Cause.UserIdCause();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
WorkspaceDescriptor desc = workspace.getDescriptor();
assertNotNull(desc);
assertEquals("Template (view generated for each node)", desc.getDisplayName());
// Log in for next set of tests...
ConnectionHelper p4 = new ConnectionHelper(auth);
p4.login();
TemplateWorkspaceImpl.DescriptorImpl impl = (TemplateWorkspaceImpl.DescriptorImpl) desc;
FormValidation form = impl.doCheckTemplateName("test.ws");
assertEquals(FormValidation.Kind.OK, form.kind);
AutoCompletionCandidates list = WorkspaceDescriptor.doAutoCompleteTemplateName("t");
assertTrue(list.getValues().contains("test.ws"));
form = WorkspaceDescriptor.doCheckFormat(format);
assertEquals(FormValidation.Kind.OK, form.kind);
}
示例9: testFreeStyleProject_StreamWs
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testFreeStyleProject_StreamWs() throws Exception {
String stream = "//stream/main";
String format = "jenkins-${node}-${project}.ws";
FreeStyleProject project = jenkins.createFreeStyleProject("Stream-Head");
StreamWorkspaceImpl workspace = new StreamWorkspaceImpl("none", false, stream, format);
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
FreeStyleBuild build;
Cause.UserIdCause cause = new Cause.UserIdCause();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
WorkspaceDescriptor desc = workspace.getDescriptor();
assertNotNull(desc);
assertEquals("Streams (view generated by Perforce for each node)", desc.getDisplayName());
// Log in for next set of tests...
ConnectionHelper p4 = new ConnectionHelper(auth);
p4.login();
FormValidation form = WorkspaceDescriptor.doCheckStreamName("//stream/main");
assertEquals(FormValidation.Kind.OK, form.kind);
AutoCompletionCandidates list = WorkspaceDescriptor.doAutoCompleteStreamName("//");
assertTrue(list.getValues().contains("//stream/main"));
form = WorkspaceDescriptor.doCheckFormat(format);
assertEquals(FormValidation.Kind.OK, form.kind);
// delete worksapce
project.doDoWipeOutWorkspace();
}
示例10: testTPI95
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testTPI95() throws Exception {
String client = "test.ws";
String format = "jenkins-${node}-${project}.ws";
FreeStyleProject project = jenkins.createFreeStyleProject("TPI95");
TemplateWorkspaceImpl workspace = new TemplateWorkspaceImpl("none", false, client, format);
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
List<ParameterValue> list = new ArrayList<ParameterValue>();
list.add(new StringParameterValue(ReviewProp.STATUS.toString(), "shelved"));
list.add(new StringParameterValue(ReviewProp.REVIEW.toString(), "19"));
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());
List<String> log = build.getLog(LOG_LIMIT);
assertTrue(log.contains("P4 Task: unshelve review: 19"));
// TPI-95 Second build with template ws
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例11: testFreeStyleProject_SpecWs
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testFreeStyleProject_SpecWs() throws Exception {
String client = "jenkins-${JOB_NAME}";
String specPath = "//depot/spec/test1";
String specFile = ""
+ "Client: jenkins-${JOB_NAME}\n"
+ "Owner: pallen\n"
+ "Root: /tmp\n"
+ "Options: noallwrite noclobber nocompress unlocked nomodtime rmdir\n"
+ "SubmitOptions: submitunchanged\n"
+ "LineEnd: local\n"
+ "View:\n"
+ "\t//depot/Data/... //jenkins-${JOB_NAME}/...\n";
submitFile(jenkins, specPath, specFile);
FreeStyleProject project = jenkins.createFreeStyleProject("Spec-Head");
SpecWorkspaceImpl workspace = new SpecWorkspaceImpl("none", false, client, specPath);
Populate populate = new AutoCleanImpl();
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
FreeStyleBuild build;
Cause.UserIdCause cause = new Cause.UserIdCause();
build = project.scheduleBuild2(0, cause).get();
assertEquals(Result.SUCCESS, build.getResult());
WorkspaceDescriptor desc = workspace.getDescriptor();
assertNotNull(desc);
assertEquals("Spec File (load workspace spec from file in Perforce)", desc.getDisplayName());
List<String> log = build.getLog(LOG_LIMIT);
assertTrue(log.contains("P4 Task: syncing files at change: 18"));
assertTrue(log.contains("... totalFileCount 6"));
}
示例12: testFreeStyleForceSync
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testFreeStyleForceSync() 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("FreeGraph");
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", false, client, spec);
Populate populate = new GraphHybridImpl(false, "10279", null);
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, populate);
project.setScm(scm);
project.save();
List<ParameterValue> list = new ArrayList<ParameterValue>();
list.add(new StringParameterValue(ReviewProp.STATUS.toString(), "committed"));
list.add(new StringParameterValue(ReviewProp.CHANGE.toString(), "10279"));
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());
List<String> log = build.getLog(LOG_LIMIT);
assertNotNull(log);
assertTrue(log.contains("P4 Task: syncing files at change: 10279"));
assertTrue(log.contains("... totalFileCount 75"));
}
示例13: testPollingPin
import hudson.model.Cause; //导入方法依赖的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());
}
示例14: resolveCause
import hudson.model.Cause; //导入方法依赖的package包/类
@Override
public TriggerCause resolveCause(Cause cause) {
if (cause instanceof Cause.UserIdCause) {
return new TriggerCause(TriggerCause.TYPE_MANUAL, "user "
+ getDisplayName(((Cause.UserIdCause) cause).getUserName()));
} else if (cause instanceof Cause.RemoteCause) {
return new TriggerCause(TriggerCause.TYPE_REMOTE, "remote trigger");
} else if (cause instanceof Cause.UpstreamCause) {
Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause;
AbstractProject upstreamProject = JenkinsUtil.getInstance().getItem(upstreamCause.getUpstreamProject(),
JenkinsUtil.getInstance(), AbstractProject.class);
StringBuilder causeString = new StringBuilder("upstream project");
if (upstreamProject != null) {
causeString.append(" ").append(upstreamProject.getDisplayName());
AbstractBuild upstreamBuild = upstreamProject.getBuildByNumber(upstreamCause.getUpstreamBuild());
if (upstreamBuild != null) {
causeString.append(" build ").append(upstreamBuild.getDisplayName());
}
}
return new TriggerCause(TriggerCause.TYPE_UPSTREAM, causeString.toString());
} else if (cause instanceof Cause.UpstreamCause.DeeplyNestedUpstreamCause) {
return new TriggerCause(TriggerCause.TYPE_UPSTREAM, "upstream");
} else if (cause instanceof SCMTrigger.SCMTriggerCause) {
return new TriggerCause(TriggerCause.TYPE_SCM, "SCM");
} else if (cause instanceof TimerTrigger.TimerTriggerCause) {
return new TriggerCause(TriggerCause.TYPE_TIMER, "timer");
} else {
return null;
}
}
示例15: testPollingInc
import hudson.model.Cause; //导入方法依赖的package包/类
@Test
public void testPollingInc() 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("PollingInc");
ManualWorkspaceImpl workspace = new ManualWorkspaceImpl("none", false, client, spec);
// Pin at label auto15
Populate populate = new AutoCleanImpl(true, true, false, false, "auto15", null);
List<Filter> filter = new ArrayList<Filter>();
FilterPerChangeImpl inc = new FilterPerChangeImpl(true);
filter.add(inc);
PerforceScm scm = new PerforceScm(CREDENTIAL, workspace, filter, populate, null);
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 incrementally
LogTaskListener listener = new LogTaskListener(logger, Level.INFO);
PollingResult found = project.poll(listener);
assertEquals(PollingResult.BUILD_NOW, found);
// Build now
build = project.scheduleBuild2(0, cause).get();
List<String> log = build.getLog(LOG_LIMIT);
assertTrue(log.contains("P4 Task: syncing files at change: 4"));
}