Creating Project, VCSRoots and BuildTypes via server side plugin
Hi,
I'd like to be able to create a plugin that allows me to create a project, its VCSRoots and its build types.
I'm stuck on how to create my svn vcsroots and add them to the project.
Can someone post some snippets?
Thanks,
SH
Please sign in to leave a comment.
scoheb wrote:
Looks you've found a hole in our OpenAPI - you cannot create VcsRoot using it.
You can try to instantiate VcsRootImpl using the following static method of VcsRootImpl:
public static SVcsRoot createOn(Map<String, String> properties, String projectId) {
String vcsName = properties.get(VCS);
if (vcsName == null) {
vcsName = "unknown";
}
final String checkoutRoot = properties.get(CHECKOUT_ROOT);
final VcsRootImpl vcsRoot = new VcsRootImpl(vcsName, checkoutRoot == null ? "" : checkoutRoot,
projectId);
properties.remove(CHECKOUT_ROOT);
vcsRoot.addAllProperties(properties);
return vcsRoot;
}
It's pretty general, specific properties depend on VCS you use.
We'll try to improve the API in the nearest future.
Regards,
KIR
--
Kirill Maximov
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Can I not do this?
public myPlugin(final SBuildServer server) {
myServer = server;
}
public myMethod (String project name) {
SProject bproj = myServer.getProjectManager().createProject(project);
bproj.setDescription(desc);
VcsRootImpl common = new VcsRootImpl("svn", "/my/checkout/path");
common.addProperty(SvnSupport.URL, "http://svn_url");
common.addProperty(SvnSupport.USER, "user");
common.addProperty(SvnSupport.PASSWORD, "pass");
common.setVcsSupport(myServer.getVcsManager().findVcsByName("svn"));
bproj.addVcsRoot(common);
}
I also can't seem to find out how to create a BuildType... Any hints?
scoheb wrote:
In the SProject interface, there is
SBuildType createBuildType(@NotNull String name,
@NotNull String runnerType,
boolean oneRunningInstance,
boolean checkoutOnServer)
throws DuplicateBuildTypeNameException;
runnerType should correspond to the name of existing
RunType (see SBuildserver::getRunTypeRegistry() method to get information about
existing RunTypes).
Hope, this helps.
KIR
--
Kirill Maximov
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Sorry, I didn't understand the question.
Do you want some other way to create VcsRoot?
BTW, you don't have to set vcsSupport to the root, project does it in
addVcsRoot.
--
Olesya Smirnova
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"scoheb" <no_reply@jetbrains.com> wrote in message
news:18625648.1164054447227.JavaMail.itn@is.intellij.net...
>
>
>
Hi,
I can't find this part
in the latest teamcity jars (4.5.4).
How has this changed ?
I am trying to add vcs roots to a SBuildType.
also, how can I get a hold on the instance of SBuildServer ?
Hello,
In TeamCity 4.5 you should obtain VcsManager object and use its methods to create a VCS Root.
To obtain either VcsManager, or SBuildServer, simply ask for this interface in constructor parameters of your bean - and Spring will provide them.
Hope this helps,
KIR
thanks, that helped.
How can I find out what keys to use in VCS root options map, Map<String, String> options of createNewVcsRoot for CVS?
There are no docs for this.
You can view source of the VCS settings page for a particular VCS root type, and see which fields are available there (see 'name' attribute for the input fields, and remove prop: prefix from them).
Or you can use something like Firebug plugin to inspect fields on the page.
HTH,
KIR