有一些maven项目。我想将其更改为jenkins中的脚本管道
要自动化以下示例,您可以通过groovy脚本控制台或groovy系统脚本使用Jenkins API以编程方式创建作业。
脚本化管道示例:
node{
stage ('Build') {
git url: 'https://github.com/cyrille-leclerc/multi-module-maven-project'
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'M3',
// Maven settings.xml file defined with the Jenkins Config File Provider Plugin
// Maven settings and global settings can also be defined in Jenkins Global Tools Configuration
mavenSettingsConfig: 'my-maven-settings',
mavenLocalRepo: '.repository') {
// Run the maven build
sh "mvn clean install"
} // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs reports...
}
}
你需要Pipeline Maven插件:https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin