0

因此,我创建了一个简单的团队城市通知程序,此时它只会将一些信息记录到我的 C 盘,但是每当在 TeamCity 上触发构建时,通知程序就不会运行。我不确定我错过了什么。这是我到目前为止所拥有的。MyLogger 类只获取一个简单的 java.util.logging.Logger 对象,该对象在 C 驱动器上创建一个日志。

这是我对 Notificator 接口的实现:

import java.util.Collection;
import java.util.Set;
import java.util.logging.Logger;

import jetbrains.buildServer.Build;
import jetbrains.buildServer.notification.Notificator;
import jetbrains.buildServer.notification.NotificatorRegistry;
import jetbrains.buildServer.responsibility.ResponsibilityEntry;
import jetbrains.buildServer.responsibility.TestNameResponsibilityEntry;
import jetbrains.buildServer.serverSide.SBuildType;
import jetbrains.buildServer.serverSide.SProject;
import jetbrains.buildServer.serverSide.SRunningBuild;
import jetbrains.buildServer.serverSide.STest;
import jetbrains.buildServer.serverSide.mute.MuteInfo;
import jetbrains.buildServer.tests.TestName;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.VcsRoot;

public class TestNotificator implements Notificator {

    private Logger log;

    public TestNotificator(NotificatorRegistry nR) {
        log = MyLogger.getLogger();
        log.info("Registering the Notificator");
        nR.register(this);
    }

    public void doNotifications(SRunningBuild arg0) {
        log.info("Do Notifications has been called");
    }

    @Override
    public String getDisplayName() {
        return "Test Notificator";
    }

    @Override
    public String getNotificatorType() {
        return "testNotificator";
    }

    @Override
    public void notifyBuildFailed(SRunningBuild arg0, Set<SUser> arg1) {
        log.info("Build has failed");
        doNotifications(arg0);

    }

    @Override
    public void notifyBuildFailedToStart(SRunningBuild arg0, Set<SUser> arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyBuildFailing(SRunningBuild arg0, Set<SUser> arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyBuildProbablyHanging(SRunningBuild arg0, Set<SUser> arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyBuildStarted(SRunningBuild arg0, Set<SUser> arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyBuildSuccessful(SRunningBuild arg0, Set<SUser> arg1) {
        log.info("Build was Successfull");
        doNotifications(arg0);
    }

    @Override
    public void notifyLabelingFailed(Build arg0, VcsRoot arg1, Throwable arg2,
            Set<SUser> arg3) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyResponsibleAssigned(SBuildType arg0, Set<SUser> arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyResponsibleAssigned(TestNameResponsibilityEntry arg0,
            TestNameResponsibilityEntry arg1, SProject arg2, Set<SUser> arg3) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyResponsibleAssigned(Collection<TestName> arg0,
            ResponsibilityEntry arg1, SProject arg2, Set<SUser> arg3) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyResponsibleChanged(SBuildType arg0, Set<SUser> arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyResponsibleChanged(TestNameResponsibilityEntry arg0,
            TestNameResponsibilityEntry arg1, SProject arg2, Set<SUser> arg3) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyResponsibleChanged(Collection<TestName> arg0,
            ResponsibilityEntry arg1, SProject arg2, Set<SUser> arg3) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyTestsMuted(Collection<STest> arg0, MuteInfo arg1,
            Set<SUser> arg2) {
        // TODO Auto-generated method stub

    }

    @Override
    public void notifyTestsUnmuted(Collection<STest> arg0, MuteInfo arg1,
            SUser arg2, Set<SUser> arg3) {
        // TODO Auto-generated method stub

    }

}

这是 build-server-plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="constructor">
  <bean id="testNotifier" class="com.testnot.TestNotificator"/>
</beans>

我将类和 build-server-plugin.xml 打包在同一个 jar 中。在 jar 中有两个单独的目录,分别是 com.testnot 和 META-INF。也许我没有正确包装它们。我不完全确定我做错了什么。任何帮助将不胜感激。我一直在使用此处找到的示例。

4

1 回答 1

1

所以在终于找到日志后,我发现你必须用Java 6编译插件,它与Java 7不兼容。经过这个更改,插件现在正在运行。

于 2012-04-27T12:59:13.327 回答