【问题标题】:Getting Project Version from Node / package.json in Jenkins在 Jenkins 中从 Node / package.json 获取项目版本
【发布时间】:2021-02-06 22:03:11
【问题描述】:

我们如何从 Jenkins 中的节点项目的 package.json 中获取项目版本?

【问题讨论】:

    标签: node.js reactjs jenkins


    【解决方案1】:

    在您的 Jenkinsfile 中使用它从 package.json 获取项目版本

    stage('Read JSON') {
             steps {
                 script {
                def packageJSON = readJSON file: 'package.json'
                def packageJSONVersion = packageJSON.version
                echo "${packageJSONVersion}"
             }
             }
          }
    

    更多参考:https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readjson-read-json-from-files-in-the-workspace

    【讨论】:

      猜你喜欢
      • 2012-04-11
      • 1970-01-01
      • 2019-09-01
      • 2017-04-28
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 2018-02-09
      • 2023-03-30
      相关资源
      最近更新 更多