【问题标题】:Not able to read parameters from properties file in jenkins无法从詹金斯的属性文件中读取参数
【发布时间】:2016-11-09 22:47:38
【问题描述】:

这就是我想要实现的目标。 - 我的 Jenkins 工作中有两个“选择参数”。第一个选择参数的值是硬编码的。应根据第一选择列表选择填充第二选择列表。我在 Jenkins 中保存了一个属性文件,其中包含键值对。首选列表中的值和文件中的 Keys 相同。在第一选择列表中选择一个值时,我想要一个代码来读取属性文件并使用与该键对应的文件中的值填充第二选择参数。 对于第二选择列表,我正在尝试使用“Active Choice Reactive Parameter”,Referenced parameters= first_choice 和以下 groovy 脚本。但这不会返回任何值。请帮忙!

 def firstChoice = [first_choice]
 Properties props = new Properties()
 def stream = new FileInputStream('C:/Jenkins/books.properties')
 try{
     props.load(stream)
    }
    catch (Exception ex){
     println "Exception"
    }
    finally {
      stream.close()
    }
 def values = props.getProperty(firstChoice).split(",")
 return values

【问题讨论】:

    标签: jenkins jenkins-groovy


    【解决方案1】:

    您的工作中是否定义了参数?如果您尝试注入作业中未定义的参数,则需要在加载主服务时定义它们或在 Jenkins 中添加异常。

    更多阅读: https://wiki.jenkins-ci.org/display/JENKINS/Plugins+affected+by+fix+for+SECURITY-170

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多