4 comments
Comment actions Permalink

We do not have much changes in OpenAPI since 1.2. New methods and classes
were added but I do not recall any significant changes. As for AntRunType
class it was not in our open api in 1.2 as well as in 2.0 since this is a
concrete implementation of server part of ant runner. If you find a change
in OpenAPI that you think should be mentioned in our documentaion feel free
to inform us.

--
Pavel Sher

"scoheb" <no_reply@jetbrains.com> wrote in message
news:1358284.1176750151413.JavaMail.itn@is.intellij.net...

Hi,

>

Are there plans to create a document, describing the OpenAPI changes from
TC 1.2 -> TC 2.0? There was one for TC 1.2 at
http://www.jetbrains.net/confluence/display/TW/Plugin+Development.

>

Things such as the disappearance of
jetbrains.buildServer.runner.ant.AntRunType make migrating custom plugins
a little bit difficult.

>

Thanks,

>

Scott



0
Comment actions Permalink

I guess I may not be using the OpenAPI to create my plugins.

Here's an example of a custom RunType that I had created. It's called CAEAntRunType and I needed it to be able to create some files on the agent prior to starting a build.

I use the WEB-INF/lib/.jar as my classpath to compile the server plugin and agent/lib/.jar to compile the agent plugin.

With TC 2.0, both jetbrains.buildServer.runner.ant.AntRunType and jetbrains.buildServer.agent.ant.AntBuildRunner cannot be resolved.

On the agent, we have the Runner:

+package com.cae.teamcity.agent;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;

import org.apache.log4j.Logger;

import com.intellij.execution.configurations.GeneralCommandLine;

import jetbrains.buildServer.agent.BuildAgentConfiguration;
import jetbrains.buildServer.agent.ant.AntBuildRunner;
import jetbrains.buildServer.agent.ant.ServerLoggerFacade;

public class CAEAntRunner extends AntBuildRunner{

private final String RERUN = "rerun";
private final String RERUN_PROTOTYPE = RERUN + "-prototype";
private final String id = "$Id: CAEAntRunner.java 438 2006-11-21 17:00:22Z scoheb $";

protected GeneralCommandLine buildCommandLine(File arg0, Map arg1, Map arg2) throws IOException {
GeneralCommandLine tmp = super.buildCommandLine(arg0, arg1, arg2);

Logger sf = Logger.getLogger(this.getClass());
sf.info(id);

// Get command line and write it to a file.
try {
String rerun;
String rerunp;
if (System.getProperty("os.name").indexOf("Win") >= 0) {
rerun = RERUN + ".bat";
rerunp = RERUN_PROTOTYPE + ".bat";
} else {
rerun = RERUN + ".sh";
rerunp = RERUN_PROTOTYPE + ".sh";
}

sf.info("Creating " + arg0.getAbsolutePath() + "/" + rerun + " for rerun purposes");
sf.info("Creating " + arg0.getAbsolutePath() + "/" + rerunp + " for rerun purposes (using prototype target)");

// Remove -listener jetbrains.buildServer.agent.ant.AgentBuildListener from command line
String cmdLine = tmp.getCommandLineString().replaceAll("-listener jetbrains.buildServer.agent.ant.AgentBuildListener", " ");
String cmdLineP = "";
String[] splitCmdLine = cmdLine.split(" ");
int l = splitCmdLine.length;
splitCmdLine[l-1] = "prototype";
for (int i = 0 ; i < l ; i++) {
cmdLineP = cmdLineP + " " + splitCmdLine+;
}

BufferedWriter out = new BufferedWriter(new FileWriter(arg0.getAbsolutePath() + "/" + rerun));
out.write(cmdLine);
out.close();

out = new BufferedWriter(new FileWriter(arg0.getAbsolutePath() + "/" + rerunp));
out.write(cmdLineP);
out.close();
} catch (IOException e) {
}
return tmp;
}

public boolean canRun(BuildAgentConfiguration arg0) {
return super.canRun(arg0);
}

public String getType() {
return "CAEAnt";
}

}

+and on the Server, we have the RunType:

+package com.cae.teamcity.agent.serverside;

import java.util.List;
import java.util.Map;

import jetbrains.buildServer.BuildTypeDescriptor.CheckoutType;
import jetbrains.buildServer.runner.ant.AntRunType;
import jetbrains.buildServer.serverSide.PropertiesProcessor;
import jetbrains.buildServer.serverSide.RunType;
import jetbrains.buildServer.serverSide.RunTypeRegistry;

public class CAEAntRunType implements RunType{

private AntRunType antRunType;
final String id = "$Id: CAEAntRunType.java 437 2006-11-21 16:58:42Z scoheb $";

public CAEAntRunType(RunTypeRegistry arg0) {
List types = arg0.getRegisteredRunTypes();
for (int i = 0 ; i < types.size() ; i++) {
RunType runT = (RunType)types.get(i);
if (runT.getType().startsWith("Ant")) {
antRunType = (AntRunType)runT;
}
}
arg0.registerRunType(this);
}

public Map getDefaultRunnerProperties() {
return antRunType.getDefaultRunnerProperties();
}

public String getDescription() {
return id;
}

public String getEditRunnerParamsJspFilePath() {
return antRunType.getEditRunnerParamsJspFilePath();
}

public PropertiesProcessor getRunnerPropertiesProcessor() {
return antRunType.getRunnerPropertiesProcessor();
}

public String getType() {
return "CAEAnt";
}

public String getViewRunnerParamsJspFilePath() {
return antRunType.getViewRunnerParamsJspFilePath();
}

public String getPluginName() {
// TODO Auto-generated method stub
return null;
}

public boolean isCheckoutTypeSupported(CheckoutType arg0) {
return true;
}

}
+

*Can you tell me if I'm doing something incorrect?
*
Thanks,

Scott

0
Comment actions Permalink

If you wish to access AntRunType class you should add WEB-INF/classes to the
classpath as well. You are right - prior to version 2.0 this class was in a
jar but then we moved it to classes.

AntBuildRunner is a part of Ant runner plugin. It is placed in the
buildServerAntRunner.jar from the /update/plugins/antPlugin.zip archive. I should mention once again - these classes are part of our internal implementation and we can't guarantee that they are not changed in the next versions. By the way could you please describe in more details why do you need to write such a plugin? What files and for what purposes does it create? -- Pavel Sher "Scott Hebert" wrote in message news:24861322.1176812976937.JavaMail.itn@is.intellij.net... >I guess I may not be using the OpenAPI to create my plugins. >]]>

Here's an example of a custom RunType that I had created. It's called
CAEAntRunType and I needed it to be able to create some files on the agent
prior to starting a build.

>

I use the WEB-INF/lib/*.jar as my classpath to compile the server plugin
and agent/lib/*.jar to compile the agent plugin.

>

With TC 2.0, both jetbrains.buildServer.runner.ant.AntRunType and
jetbrains.buildServer.agent.ant.AntBuildRunner cannot be resolved.

>

On the agent, we have the Runner:

>

+package com.cae.teamcity.agent;

>

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;

>

import org.apache.log4j.Logger;

>

import com.intellij.execution.configurations.GeneralCommandLine;

>

import jetbrains.buildServer.agent.BuildAgentConfiguration;
import jetbrains.buildServer.agent.ant.AntBuildRunner;
import jetbrains.buildServer.agent.ant.ServerLoggerFacade;

>

public class CAEAntRunner extends AntBuildRunner{

>

private final String RERUN = "rerun";
private final String RERUN_PROTOTYPE = RERUN + "-prototype";
private final String id = "$Id: CAEAntRunner.java 438 2006-11-21 17:00:22Z
scoheb $";

>

protected GeneralCommandLine buildCommandLine(File arg0, Map arg1, Map
arg2) throws IOException {
GeneralCommandLine tmp = super.buildCommandLine(arg0, arg1, arg2);

>

Logger sf = Logger.getLogger(this.getClass());
sf.info(id);

>

// Get command line and write it to a file.
try {
String rerun;
String rerunp;
if (System.getProperty("os.name").indexOf("Win") >= 0) {
rerun = RERUN + ".bat";
rerunp = RERUN_PROTOTYPE + ".bat";
} else {
rerun = RERUN + ".sh";
rerunp = RERUN_PROTOTYPE + ".sh";
}

>

sf.info("Creating " + arg0.getAbsolutePath() + "/" + rerun + " for rerun
purposes");
sf.info("Creating " + arg0.getAbsolutePath() + "/" + rerunp + " for rerun
purposes (using prototype target)");

>

// Remove -listener jetbrains.buildServer.agent.ant.AgentBuildListener
from command line
String cmdLine = tmp.getCommandLineString().replaceAll("-listener
jetbrains.buildServer.agent.ant.AgentBuildListener", " ");
String cmdLineP = "";
String[] splitCmdLine = cmdLine.split(" ");
int l = splitCmdLine.length;
splitCmdLine[l-1] = "prototype";
for (int i = 0 ; i < l ; i++) {
cmdLineP = cmdLineP + " " + splitCmdLine+;
}

>

BufferedWriter out = new BufferedWriter(new
FileWriter(arg0.getAbsolutePath() + "/" + rerun));
out.write(cmdLine);
out.close();

>

out = new BufferedWriter(new FileWriter(arg0.getAbsolutePath() +
"/" + rerunp));
out.write(cmdLineP);
out.close();
} catch (IOException e) {
}
return tmp;
}

>

public boolean canRun(BuildAgentConfiguration arg0) {
return super.canRun(arg0);
}

>

public String getType() {
return "CAEAnt";
}

>

}

>

+and on the Server, we have the RunType:

>

+package com.cae.teamcity.agent.serverside;

>

import java.util.List;
import java.util.Map;

>

import jetbrains.buildServer.BuildTypeDescriptor.CheckoutType;
import jetbrains.buildServer.runner.ant.AntRunType;
import jetbrains.buildServer.serverSide.PropertiesProcessor;
import jetbrains.buildServer.serverSide.RunType;
import jetbrains.buildServer.serverSide.RunTypeRegistry;

>

public class CAEAntRunType implements RunType{

>

private AntRunType antRunType;
final String id = "$Id: CAEAntRunType.java 437 2006-11-21 16:58:42Z scoheb
$";

>

public CAEAntRunType(RunTypeRegistry arg0) {
List types = arg0.getRegisteredRunTypes();
for (int i = 0 ; i < types.size() ; i++) {
RunType runT = (RunType)types.get(i);
if (runT.getType().startsWith("Ant")) {
antRunType = (AntRunType)runT;
}
}
arg0.registerRunType(this);
}

>

public Map getDefaultRunnerProperties() {
return antRunType.getDefaultRunnerProperties();
}

>

public String getDescription() {
return id;
}

>

public String getEditRunnerParamsJspFilePath() {
return antRunType.getEditRunnerParamsJspFilePath();
}

>

public PropertiesProcessor getRunnerPropertiesProcessor() {
return antRunType.getRunnerPropertiesProcessor();
}

>

public String getType() {
return "CAEAnt";
}

>

public String getViewRunnerParamsJspFilePath() {
return antRunType.getViewRunnerParamsJspFilePath();
}

>

public String getPluginName() {
// TODO Auto-generated method stub
return null;
}

>

public boolean isCheckoutTypeSupported(CheckoutType arg0) {
return true;
}

>

}
+

>

*Can you tell me if I'm doing something incorrect?
*
Thanks,

>

Scott



0
Comment actions Permalink

Hi Pavel,

Thanks for your response.

My plugin creates a file (called rerun.sh|.bat) which contains the exact same command line that was used by TC to start the build. It also removes the TC listener since the server would not know about the existence of this manual execution of the build. Since some of my builds take quite a while (3-6 hrs), I need a way to restart it manually from the place where there was an error. These files enable this.

Thanks,

Scott

0

Please sign in to leave a comment.