0
我最近開始編寫Jenkins聲明性流水線(CVS中的Jenkinsfile),並分幾個階段。在Jenkins聲明性流水線中定義全局Ant工具
我想知道是否有辦法只定義Ant一次,然後在所有階段重複使用相同的命令。
而不是重複蝙蝠「%ANT_HOME%/ bin中/ ant.bat the_ant_target_to_run」的話,我寧願不要做這樣的:螞蟻乾淨編譯
pipeline {
agent any
stages {
stage("Build") {
steps {
echo "Building application..."
bat "%ANT_HOME%/bin/ant.bat clean compile"
}
}
stage("Unit Tests") {
steps {
echo "Unit tests (JUnit)..."
echo "Mutation tests (pitest)..."
bat "%ANT_HOME%/bin/ant.bat run-unit-tests"
bat "%ANT_HOME%/bin/ant.bat run-mutation-tests"
}
}
stage("Functional Test") {
steps {
echo "Selenium tests..."
}
}
stage("Performance Test") {
steps {
echo "JMeter tests..."
}
}
stage("Quality Analysis") {
steps {
echo "Running SonarQube..."
bat "%ANT_HOME%/bin/ant.bat run-sonarqube-analysis"
}
}
stage("Security Assessment") {
steps {
echo "Pen testing..."
}
}
stage("Approval") {
steps {
input "Is the build OK?"
}
}
stage("Deploy") {
steps {
echo "Deploying to JBoss 7.2..."
}
}
}
post {
always {
junit '/test/reports/*.xml'
}
}
}
我已經安裝了(名字是「螞蟻安裝」)。將嘗試它並獲取更新。 –
你能提供一個你的建議的具體例子嗎?當你說「你可以用它作爲參數」時,你使用$ antHome還是$ {antHome}來訪問它? –
DEF mvnHome 階段( '製備'){ DIR( './' + microserviceName){ deleteDir() } mvnHome =工具 '的Maven' } 階段( '生成'){// 運行maven build dir('./'+ microserviceName){ sh''$ {mvnHome}/bin/mvn'-s mvn_settings.xml -U clean install } } –