Groovy 获取 tfs 变更集的编辑类型
Groovy get edit type of tfs changeset
我需要获取 tfs 变更集文件(我已经完成了这个)以及它是否是使用 jenkins 服务器上的 groovy 插件添加或删除的。
我不知道如何访问包含获取编辑类型方法的项目 class。我已经尝试了下面的代码,但无法弄明白。
import java.lang.*
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
import hudson.util.*
import hudson.scm.*
import hudson.scm.SubversionChangeLogSet.LogEntry
import hudson.plugins.tfs.model.ChangeSet
import hudson.plugins.tfs.model.ChangeSet.Item
import groovy.util.slurpersupport.GPathResult
import groovy.xml.XmlUtil
import groovy.xml.StreamingMarkupBuilder
import java.io.Serializable
import java.lang.Cloneable
import groovy.xml.MarkupBuilder
// work with current build
def build = Thread.currentThread()?.executable
// get ChangesSets with all changed items
def changeSet = build.getChangeSet()
def items = changeSet.getItems()
println "Affected Paths"
def affectedFiles = items.collect {
it.getAffectedPaths()
}
def action = items.getAction()
println action.getEditType
有什么想法吗?
根据您的描述,您似乎希望在变更集或变更集中的文件旁边显示状态,以显示它是什么类型的操作。
在 TFS 中我们调用了 changeType,Microsoft.TeamFoundation.SourceControl.WebApi.VersionControlChangeType。
而不是在詹金斯中使用 groovy。您也可以通过 Rest API 获得它。怎么样,看看
您应该使用 returns 和 EditType 的方法。 index.jelly 然后使用该方法来确定要显示的图标。
在这里查看示例代码:
public EditType getEditType() {
if (action.equalsIgnoreCase("delete")) {
return EditType.DELETE;
}
if (action.equalsIgnoreCase("add")) {
return EditType.ADD;
}
return EditType.EDIT;
}
来源Link:jenkinsci/tfs-plugin
我需要获取 tfs 变更集文件(我已经完成了这个)以及它是否是使用 jenkins 服务器上的 groovy 插件添加或删除的。
我不知道如何访问包含获取编辑类型方法的项目 class。我已经尝试了下面的代码,但无法弄明白。
import java.lang.*
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
import hudson.util.*
import hudson.scm.*
import hudson.scm.SubversionChangeLogSet.LogEntry
import hudson.plugins.tfs.model.ChangeSet
import hudson.plugins.tfs.model.ChangeSet.Item
import groovy.util.slurpersupport.GPathResult
import groovy.xml.XmlUtil
import groovy.xml.StreamingMarkupBuilder
import java.io.Serializable
import java.lang.Cloneable
import groovy.xml.MarkupBuilder
// work with current build
def build = Thread.currentThread()?.executable
// get ChangesSets with all changed items
def changeSet = build.getChangeSet()
def items = changeSet.getItems()
println "Affected Paths"
def affectedFiles = items.collect {
it.getAffectedPaths()
}
def action = items.getAction()
println action.getEditType
有什么想法吗?
根据您的描述,您似乎希望在变更集或变更集中的文件旁边显示状态,以显示它是什么类型的操作。
在 TFS 中我们调用了 changeType,Microsoft.TeamFoundation.SourceControl.WebApi.VersionControlChangeType。
而不是在詹金斯中使用 groovy。您也可以通过 Rest API 获得它。怎么样,看看
您应该使用 returns 和 EditType 的方法。 index.jelly 然后使用该方法来确定要显示的图标。
在这里查看示例代码:
public EditType getEditType() {
if (action.equalsIgnoreCase("delete")) {
return EditType.DELETE;
}
if (action.equalsIgnoreCase("add")) {
return EditType.ADD;
}
return EditType.EDIT;
}
来源Link:jenkinsci/tfs-plugin