我在自学詹金斯,没有太多经验。我刚刚发现了警告ng插件,我正在尝试访问我的管道中的令牌:
pipeline {
agent any
stages {
stage('analysis') {
steps {
script{
bat'''
cppcheck "C:/Users/anton/Desktop/railway" --xml --xml-version=2 . 2> cppcheck.xml
'''
}
}
}
stage('Test'){
steps {
script {
def cppCheck = scanForIssues tool: cppCheck(pattern: 'cppcheck.xml')
publishIssues issues: [cppCheck]
echo "${ANALYSIS_ISSUES_COUNT}"
}
}
}
}
}
正如警告ng文档中提到的,但我得到了一个错误No such property: ANALYSIS_ISSUES_COUNT for class: groovy.lang.Binding
访问令牌的正确语法是什么?或者在访问它之前需要做什么吗?据我所知,我只需要安装令牌宏插件,我已经安装了,而警告ng插件提供了这些令牌,可以访问,我错了吗?
使用tm步骤。
def newIssuesCountString = tm stringWithMacro: '${ANALYSIS_ISSUES_COUNT, type="NEW"}'
int newIssuesCount = newIssuesCountString as int
def totalIssuesCountString = tm stringWithMacro: '${ANALYSIS_ISSUES_COUNT, type="TOTAL"}'
int totalIssuesCount = totalIssuesCountString as int
参考1:https://www.jenkins.io/doc/pipeline/steps/token-macro/
参考2:https://github.com/jenkinsci/warnings-ng-plugin/blob/master/doc/Documentation.md#token-宏支持