有没有办法以自动方式将maven项目转换为管道

问题描述 投票:0回答:1

有一些maven项目。我想将其更改为jenkins中的脚本管道

jenkins jenkins-pipeline jenkins-plugins
1个回答
0
投票

要自动化以下示例,您可以通过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

© www.soinside.com 2019 - 2024. All rights reserved.