How to read properties file from Jenkins 2.0 pipeline script

前端 未结 4 1786
终归单人心
终归单人心 2020-12-03 10:44

I am attempting to write a pipeline script to use with Jenkins 2.0 to replicate our existing build. This original build used the envInject plugin to read a Java properties

4条回答
  •  天命终不由人
    2020-12-03 11:17

    i wasn't able to figure out how to interpolate the plain text from readProperties, so i just made a workaround to expand the variable.

    def props = readProperties  file: 'dir/my.properties'
    def release = expand_property(props['RELEASE'])
    
    def expand_property(property) {
      def info 
      node("anyUnixNode") {
        info = sh(script: "echo $property", returnStdout: true)
      }
      info = info.trim()
      return info   
    }
    

提交回复
热议问题