FSTrigger 在詹金斯中不正确地触发

FSTrigger triggers incorrectly in jenkins

我在outlook里设置了规则

apply this rule after arrives
with "xyz" in the subject
and move it to the "buildme"

文件夹 "buildme" 已在

创建为数据文件

C:\Users\myid\AppData\Local\Microsoft\Outlook\builme.pst

在项目下的Jenkin中,我创建了构建触发器如下:

[FSTrigger] - Monitor files
File Path: C:\Users\myid\AppData\Local\Microsoft\Outlook\builme.pst
Schedule: 55 * * * 1-5

我发送了一封主题行为 "xyz" 的电子邮件。 然后电子邮件被移动到 "buildme" 文件夹,因此文件 C:\Users\myid\AppData\Local\Microsoft\Outlook\builme.pst 得到更新,例如“3/24/2016 11:24 AM”。

在 11:55 上午,正确触发了构建。

然而,在12:55下午,再次触发了另一个构建,出乎意料的是,尽管没有发送新的电子邮件。这种情况每小时都会发生。

我做错了什么?

Outlook 可能以某种方式修改了文件,修改了一些导致 FSTrigger 开始构建的时间戳。

为了稳健起见,我建议不要依赖监视 outlook 文件夹文件的更改,因为它可能会意外更改。而是修改您的规则以直接触发 jenkins 服务器上的构建作业。

即伪代码:IF subject CONTAINS keyword ACCESS jenkinsurl_that_starts_build

如何 运行 一个基于 outlook 规则的脚本似乎被布局 here 并且 有关如何通过 jenkins url 上的 http 请求触发构建的信息已解释 here

您将来甚至可以扩展它以将参数从您的电子邮件传递到您的构建,因为这些也可以通过 url 访问进行设置。有关此 here 的更多信息,第 使用参数启动构建

我将规则更改为:

apply this rule after arrives 
with "xyz" in the subject 
run projetcs.ThisOutlookSession.WriteStringToFile

和 VBA 脚本:

Sub WriteStringToFile1(MyMail As MailItem)
    Const FILEPATH = "c:\buildtrigger\testtest.txt"

    Dim strSubject As String
    Dim strSender As String
    Dim strText As String
    Dim strID As String
    Dim objMail As Outlook.MailItem

    strID = MyMail.EntryID
    Set objMail = Application.Session.GetItemFromID(strID)

    strSubject = objMail.Subject
    strSender = objMail.SenderName


    Open FILEPATH For Output As 1
    Print #1, "SET XYZ = " & strSubject & ";" & strSender & "--" & Now
    Close #1

End Sub

此 VBA 脚本将写一行到 testtest.txt。

在 Jenkins 中,创建构建触发器:

[FSTrigger] - Monitor folder
Path = c:\buildtrigger
Includes = testtest.txt
Exclude check lastModification date = true
Exclude check content = false
Exclude check fewer or more files = true
schedule: * * * * 1-5

发送主题为xyz的邮件,将成功触发构建,未收到邮件时不触发构建。

附带说明一下,文件的时间戳似乎是由 FSTrigger 修改的,而不是 Outlook 或 Windows。