Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 172896 Details for
Bug 317384
[build] add "Run build" functionality
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Running builds
mylyn-run-build.diff (text/plain), 14.38 KB, created by
Markus Knittig
on 2010-06-28 08:41:23 EDT
(
hide
)
Description:
Running builds
Filename:
MIME Type:
Creator:
Markus Knittig
Created:
2010-06-28 08:41:23 EDT
Size:
14.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.builds.core >Index: src/org/eclipse/mylyn/builds/core/IBuildPlan.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/core/IBuildPlan.java,v >retrieving revision 1.4 >diff -u -r1.4 IBuildPlan.java >--- src/org/eclipse/mylyn/builds/core/IBuildPlan.java 24 Jun 2010 06:07:52 -0000 1.4 >+++ src/org/eclipse/mylyn/builds/core/IBuildPlan.java 28 Jun 2010 12:39:32 -0000 >@@ -13,6 +13,9 @@ > > import java.util.List; > >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+ > /** > * @author Steffen Pingel > */ >@@ -38,4 +41,6 @@ > > public IBuildPlanWorkingCopy createWorkingCopy(); > >+ IStatus run(IOperationMonitor monitor) throws CoreException; >+ > } >Index: src/org/eclipse/mylyn/builds/core/spi/BuildServerBehaviour.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/core/spi/BuildServerBehaviour.java,v >retrieving revision 1.2 >diff -u -r1.2 BuildServerBehaviour.java >--- src/org/eclipse/mylyn/builds/core/spi/BuildServerBehaviour.java 30 May 2010 19:27:55 -0000 1.2 >+++ src/org/eclipse/mylyn/builds/core/spi/BuildServerBehaviour.java 28 Jun 2010 12:39:32 -0000 >@@ -15,6 +15,7 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.mylyn.builds.core.IBuildElement; > import org.eclipse.mylyn.builds.core.IBuildPlan; > import org.eclipse.mylyn.builds.core.IBuildServer; > import org.eclipse.mylyn.builds.core.IOperationMonitor; >@@ -38,4 +39,6 @@ > > public abstract IStatus validate(IOperationMonitor monitor) throws CoreException; > >+ public abstract IStatus runBuild(IBuildElement element, IOperationMonitor monitor) throws CoreException; >+ > } >Index: src/org/eclipse/mylyn/internal/builds/core/BuildPlan.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/internal/builds/core/BuildPlan.java,v >retrieving revision 1.6 >diff -u -r1.6 BuildPlan.java >--- src/org/eclipse/mylyn/internal/builds/core/BuildPlan.java 26 Jun 2010 23:00:56 -0000 1.6 >+++ src/org/eclipse/mylyn/internal/builds/core/BuildPlan.java 28 Jun 2010 12:39:33 -0000 >@@ -8,6 +8,8 @@ > > import java.util.Collection; > >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.common.notify.NotificationChain; > import org.eclipse.emf.common.util.EList; >@@ -24,6 +26,7 @@ > import org.eclipse.mylyn.builds.core.IBuildPlan; > import org.eclipse.mylyn.builds.core.IBuildPlanWorkingCopy; > import org.eclipse.mylyn.builds.core.IBuildServer; >+import org.eclipse.mylyn.builds.core.IOperationMonitor; > > /** > * <!-- begin-user-doc --> >@@ -1085,4 +1088,8 @@ > return newPlan; > } > >+ public IStatus run(IOperationMonitor monitor) throws CoreException { >+ return ((BuildServer) getServer()).getBehaviour().runBuild(this, monitor); >+ } >+ > } // BuildPlan >#P org.eclipse.mylyn.builds.ui >Index: src/org/eclipse/mylyn/internal/builds/ui/view/BuildsView.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.builds.ui/src/org/eclipse/mylyn/internal/builds/ui/view/BuildsView.java,v >retrieving revision 1.4 >diff -u -r1.4 BuildsView.java >--- src/org/eclipse/mylyn/internal/builds/ui/view/BuildsView.java 24 Jun 2010 06:07:56 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/builds/ui/view/BuildsView.java 28 Jun 2010 12:39:34 -0000 >@@ -117,6 +117,15 @@ > MenuManager menuManager = new MenuManager(); > > GroupMarker marker = new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS); >+ >+ OpenInBrowserAction openInBrowserAction = new OpenInBrowserAction(); >+ menuManager.add(openInBrowserAction); >+ viewer.addSelectionChangedListener(openInBrowserAction); >+ >+ RunBuildAction runBuildAction = new RunBuildAction(); >+ menuManager.add(runBuildAction); >+ viewer.addSelectionChangedListener(runBuildAction); >+ > menuManager.add(marker); > Menu contextMenu = menuManager.createContextMenu(parent); > >@@ -130,8 +139,8 @@ > tree.setHeaderVisible(true); > > TreeViewerColumn buildViewerColumn = new TreeViewerColumn(viewer, SWT.LEFT); >- buildViewerColumn.setLabelProvider(new DecoratingStyledCellLabelProvider(new BuildLabelProvider(), >- PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null)); >+ buildViewerColumn.setLabelProvider(new DecoratingStyledCellLabelProvider(new BuildLabelProvider(), PlatformUI >+ .getWorkbench().getDecoratorManager().getLabelDecorator(), null)); > TreeColumn buildColumn = buildViewerColumn.getColumn(); > buildColumn.setText("Builds"); > buildColumn.setWidth(220); >@@ -198,6 +207,10 @@ > OpenInBrowserAction openInBrowserAction = new OpenInBrowserAction(); > viewer.addSelectionChangedListener(openInBrowserAction); > manager.add(openInBrowserAction); >+ >+ RunBuildAction runBuildAction = new RunBuildAction(); >+ viewer.addSelectionChangedListener(runBuildAction); >+ manager.add(runBuildAction); > } > > TreeViewer getViewer() { >Index: src/org/eclipse/mylyn/internal/builds/ui/view/RunBuildAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/builds/ui/view/RunBuildAction.java >diff -N src/org/eclipse/mylyn/internal/builds/ui/view/RunBuildAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/builds/ui/view/RunBuildAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Markus Knittig and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Markus Knittig - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.builds.ui.view; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.mylyn.builds.core.IBuildPlan; >+import org.eclipse.mylyn.builds.core.util.ProgressUtil; >+import org.eclipse.mylyn.internal.builds.core.BuildsCorePlugin; >+import org.eclipse.mylyn.internal.builds.ui.BuildImages; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.actions.BaseSelectionListenerAction; >+ >+/** >+ * @author Markus Knittig >+ */ >+public class RunBuildAction extends BaseSelectionListenerAction { >+ >+ protected RunBuildAction() { >+ super("Run Build"); >+ setToolTipText("Run Build"); >+ setImageDescriptor(BuildImages.RUN); >+ setDisabledImageDescriptor(BuildImages.RUN_DISABLED); >+ } >+ >+ @Override >+ protected boolean updateSelection(IStructuredSelection selection) { >+ return (selection.getFirstElement() instanceof IBuildPlan); >+ } >+ >+ @Override >+ public void run() { >+ >+ IStructuredSelection selection = getStructuredSelection(); >+ for (Object object : selection.toList()) { >+ if (object instanceof IBuildPlan) { >+ final IBuildPlan plan = (IBuildPlan) object; >+ new Job("Running build...") { >+ @Override >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ return plan.run(ProgressUtil.convert(monitor)); >+ } catch (CoreException e) { >+ return new Status(IStatus.ERROR, BuildsCorePlugin.ID_PLUGIN, NLS.bind( >+ "Run of build ''{0}'' failed", plan.getName(), e)); >+ } catch (OperationCanceledException e) { >+ return Status.CANCEL_STATUS; >+ } >+ } >+ }.run(new NullProgressMonitor()); >+ } >+ } >+ } >+} >#P org.eclipse.mylyn.hudson.core >Index: src/org/eclipse/mylyn/internal/hudson/core/HudsonServerBehaviour.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.hudson.core/src/org/eclipse/mylyn/internal/hudson/core/HudsonServerBehaviour.java,v >retrieving revision 1.4 >diff -u -r1.4 HudsonServerBehaviour.java >--- src/org/eclipse/mylyn/internal/hudson/core/HudsonServerBehaviour.java 25 Jun 2010 03:05:05 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/hudson/core/HudsonServerBehaviour.java 28 Jun 2010 12:39:35 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.mylyn.builds.core.BuildState; > import org.eclipse.mylyn.builds.core.BuildStatus; >+import org.eclipse.mylyn.builds.core.IBuildElement; > import org.eclipse.mylyn.builds.core.IBuildPlan; > import org.eclipse.mylyn.builds.core.IBuildPlanWorkingCopy; > import org.eclipse.mylyn.builds.core.IBuildServer; >@@ -102,4 +103,15 @@ > } > } > >+ @Override >+ public IStatus runBuild(IBuildElement element, IOperationMonitor monitor) throws CoreException { >+ try { >+ HudsonModelJob job = new HudsonModelJob(); >+ job.setUrl(element.getUrl()); >+ return client.runBuild(job, monitor); >+ } catch (HudsonException e) { >+ throw HudsonCorePlugin.toCoreException(e); >+ } >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/hudson/core/client/RestfulHudsonClient.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.hudson.core/src/org/eclipse/mylyn/internal/hudson/core/client/RestfulHudsonClient.java,v >retrieving revision 1.3 >diff -u -r1.3 RestfulHudsonClient.java >--- src/org/eclipse/mylyn/internal/hudson/core/client/RestfulHudsonClient.java 24 Jun 2010 00:37:23 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/hudson/core/client/RestfulHudsonClient.java 28 Jun 2010 12:39:35 -0000 >@@ -53,6 +53,7 @@ > > public RestfulHudsonClient(AbstractWebLocation location) { > client = new CommonHttpClient(location); >+ client.getHttpClient().getParams().setAuthenticationPreemptive(true); > } > > protected void checkResponse(int statusCode) throws HudsonException { >@@ -128,4 +129,23 @@ > HttpStatus.getStatusText(response))); > } > >+ public IStatus runBuild(final HudsonModelJob job, final IOperationMonitor monitor) throws HudsonException { >+ int response = new HudsonOperation<Integer>(client) { >+ @Override >+ public Integer execute() throws IOException { >+ CommonHttpMethod method = createGetMethod(job.getUrl() + "/build"); >+ try { >+ return execute(method, monitor); >+ } finally { >+ method.releaseConnection(monitor); >+ } >+ } >+ }.run(); >+ if (response == HttpStatus.SC_OK) { >+ return Status.OK_STATUS; >+ } >+ throw new HudsonException(NLS.bind("Unexpected return code {0}: {1}", response, >+ HttpStatus.getStatusText(response))); >+ } >+ > } >#P org.eclipse.mylyn.hudson.tests >Index: src/org/eclipse/mylyn/hudson/tests/client/HudsonClientTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.hudson.tests/src/org/eclipse/mylyn/hudson/tests/client/HudsonClientTest.java,v >retrieving revision 1.2 >diff -u -r1.2 HudsonClientTest.java >--- src/org/eclipse/mylyn/hudson/tests/client/HudsonClientTest.java 15 Jun 2010 08:23:20 -0000 1.2 >+++ src/org/eclipse/mylyn/hudson/tests/client/HudsonClientTest.java 28 Jun 2010 12:39:36 -0000 >@@ -20,7 +20,11 @@ > import org.eclipse.mylyn.hudson.tests.support.HudsonFixture; > import org.eclipse.mylyn.internal.hudson.core.client.HudsonException; > import org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient; >+import org.eclipse.mylyn.internal.hudson.model.HudsonModelBallColor; > import org.eclipse.mylyn.internal.hudson.model.HudsonModelJob; >+import org.eclipse.mylyn.tests.util.TestUtil; >+import org.eclipse.mylyn.tests.util.TestUtil.Credentials; >+import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel; > > /** > * Test cases for {@link RestfulHudsonClient}. >@@ -60,10 +64,37 @@ > } > } > >- public void testGetPlans() throws Exception { >+ public void testGetJobs() throws Exception { > client = fixture.connect(); >- List<HudsonModelJob> plans = client.getJobs(null); >- assertEquals(plans.get(0).getName(), "failing"); >+ List<HudsonModelJob> jobs = client.getJobs(null); >+ assertEquals(jobs.get(0).getName(), "failing"); >+ } >+ >+ public void testRunBuild() throws Exception { >+ Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER); >+ >+ client = fixture.connect(HudsonFixture.HUDSON_TEST_URL, credentials.username, credentials.password); >+ >+ // failing build >+ client.runBuild(getJob("failing"), ProgressUtil.convert(null)); >+ assertEquals(getJob("failing").getColor(), HudsonModelBallColor.RED_ANIME); >+ Thread.sleep(1000); >+ assertEquals(getJob("succeeding").getColor(), HudsonModelBallColor.RED); >+ >+ // succeeding build >+ client.runBuild(getJob("succeeding"), ProgressUtil.convert(null)); >+ assertEquals(getJob("succeeding").getColor(), HudsonModelBallColor.BLUE_ANIME); >+ Thread.sleep(1000); >+ assertEquals(getJob("succeeding").getColor(), HudsonModelBallColor.BLUE); >+ } >+ >+ private HudsonModelJob getJob(String name) throws HudsonException { >+ for (HudsonModelJob job : client.getJobs(null)) { >+ if (job.getName().equals(name)) { >+ return job; >+ } >+ } >+ return null; > } > > } >Index: src/org/eclipse/mylyn/hudson/tests/support/HudsonFixture.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.hudson.tests/src/org/eclipse/mylyn/hudson/tests/support/HudsonFixture.java,v >retrieving revision 1.2 >diff -u -r1.2 HudsonFixture.java >--- src/org/eclipse/mylyn/hudson/tests/support/HudsonFixture.java 26 Jun 2010 23:11:50 -0000 1.2 >+++ src/org/eclipse/mylyn/hudson/tests/support/HudsonFixture.java 28 Jun 2010 12:39:36 -0000 >@@ -30,9 +30,9 @@ > */ > public class HudsonFixture extends TestFixture { > >- private static HudsonFixture current; >+ public final static String HUDSON_TEST_URL = "http://mylyn.eclipse.org/hudson"; > >- private final static String HUDSON_TEST_URL = "http://mylyn.eclipse.org/hudson"; >+ private static HudsonFixture current; > > private static final HudsonFixture DEFAULT = new HudsonFixture(HUDSON_TEST_URL, "1.339", "REST"); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 317384
:
172296
|
172297
|
172835
|
172836
|
172896
|
172897
|
172954
|
172955
|
172957