How to read properties file from Jenkins 2.0 pipeline script

前端 未结 4 1796
终归单人心
终归单人心 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:19

    I tried out and below works perfectly fine:

    test.properties
    Monday=abcdef
    Tuesday=kfgh
    
    def props = readProperties  file:'/var/lib/jenkins/jobs/abc/test.properties'
    def Var1= props['Monday']
    def Var2= props['Tuesday']
    echo "Var1=${Var1}"
    echo "Var2=${Var2}"
    

提交回复
热议问题