1
我正在努力創建一個我想要在Jenkins中使用腳本管道的格式的時間戳。下面是從管道我的代碼:在Jenkinsfile中創建一個時間戳
def cal = Calendar.instance
def dateFormat = 'YYYYMMDD-hhmmss'
def timeZone = TimeZone.getTimeZone('CST')
def timeStamp = cal.time.format(dateFormat,timeZone)
println "Timestamp is: ${timeStamp}"
env.BUILD_TIMESTAMP = timeStamp
當我通過詹金斯跑,我得到如下:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified field java.util.GregorianCalendar time
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:387)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:371)
我見過的與不同領域的類似問題提的在線,但增加的解決方法它到scriptapproval.xml
(並重新啓動詹金斯)似乎並沒有工作。
任何人都有類似於我想要做的格式生成時間戳的方法?
您是否在管理Jenkins下檢查了進程內腳本審批頁面?最後它和編寫scriptapproval.xml一樣,但是會給你一些關於應該批准什麼的信息。 – babsaai
@babsaai是的。我已經檢查過了。沒有什麼可以批准的。 –