与主题中一样-是否有任何方法可以验证当前版本是否是使用“重播”按钮的效果?
答案 0 :(得分:3)
我使用Private Sub Workbook_Open()
'the name of the current user
Dim UserName As String
'on opening, find out who this is (and convert to lower case)
Dim wb As Workbook
Set wb = Workbooks("Staffing Log - HQ - 2018 - 2019.xlsm")
wb.Activate
UserName = LCase(Environ("UserName"))
On Error Resume Next
Application.Visible = False
'ActiveWindow.Visible = False
Sheets("GoodDBData").Visible = True ERROR OCCURS HERE
end sub
中的rawBuild
实例找到了以下解决方案。由于我们无法找到原因的类别,因此只需验证其字符串值即可。
currentBuild
此解决方案适用于Jenkins和Blue-Ocean。关于如何获得此答案的参考是Jenkins declarative pipeline: find out triggering job
使用此步进条件就像魅力一样!
您可以定义一个共享库,例如def replayClassName = "org.jenkinsci.plugins.workflow.cps.replay.ReplayCause"
def isReplay = currentBuild.rawBuild.getCauses().any{ cause -> cause.toString().contains(replayClassName) }
jenkins.groovy
您可以在Jenkins管道中重复使用它
def isBuildAReplay() {
// https://stackoverflow.com/questions/51555910/how-to-know-inside-jenkinsfile-script-that-current-build-is-an-replay/52302879#52302879
def replyClassName = "org.jenkinsci.plugins.workflow.cps.replay.ReplayCause"
currentBuild.rawBuild.getCauses().any{ cause -> cause.toString().contains(replyClassName) }
}