美文网首页
jenkins读取pom.xml

jenkins读取pom.xml

作者: 郑码 | 来源:发表于2018-08-31 22:28 被阅读0次

    需求

    在jenkins pipeline中,需要获取pom.xml中一些信息

    实现方法

    前提:

    1. jenkins安装Pipeline Utility Steps插件
    2. 在readMavenPom出错时,要在scriptApproval允许Approvals

    安装Pipeline Utility Steps插件

    j20.png j20-1.png

    使用readMavenPom报错处理

    j21-0.png j21-1.png j21-2.png

    使用示例:

    stage('Publish') {
     def pom = readMavenPom file: 'pom.xml'
     nexusPublisher nexusInstanceId: 'nexus2', \
      nexusRepositoryId: 'releases', \
      packages: [[$class: 'MavenPackage', \
      mavenAssetList: [[classifier: '', extension: '', \
      filePath: "target/${pom.artifactId}-${pom.version}.${pom.packaging}"]], \
      mavenCoordinate: [artifactId: "${pom.artifactId}", \
      groupId: "${pom.groupId}", \
      packaging: "${pom.packaging}", \
      version: "${pom.version}"]]]
    }
    

    参考

    1. readMavenPom: Read a maven project file
    2. readMavenPom可以获取的信息
    3. Jenkins Publish Using Maven Coordinates from the pom.xml
    4. Cannot use readMavenPom in Jenkinsfile要安装 pipeline-utility-steps 插件

    相关文章

      网友评论

          本文标题:jenkins读取pom.xml

          本文链接:https://www.haomeiwen.com/subject/mtoewftx.html