0

我在 Jenkins 中使用字符串参数 DEPLOYMENT_ADDRESS 配置了参数化作业 - 默认值为 some/path/${SVN_REVISION}。

SVN_REVISION 是 Jenkins 中 shell 脚本可用的环境变量。

当我调用 ruby​​ 脚本时

ruby file_generator.rb -d $DEPLOYMENT_ADDRESS

在控制台输出中,这看起来像

ruby file_generator.rb -d 'some/path/${SVN_REVISION}'

我的脚本中的参数值是'some/path/${SVN_REVISION}'。但我需要'some/path/123'之类的东西。

我做错了什么?

更新>>

代码示例,我在其中解析参数:

require 'optparse'

option_parser = OptionParser.new do |opts|
  executable_name = File.basename($PROGRAM_NAME)
  opts.banner = "Usage: #{executable_name} [options] output_file_name"
    opts.on('-d DEPLOYMENT_ADDRESS', 'The deployment address where the file will reside') do |deployment_address|
        options[:deployment_address] = deployment_address
    end
end

option_parser.parse!

output_file_name = ARGV.shift

puts options[:deployment_address]     # => /some/path/${SVN_REVISION}. But I need somthing like /some/path/123 
4

1 回答 1

0

如果没有所需的示例代码,很难确定,但我猜您使用单引号来分隔字符串,而不是所需的双引号或不正确的嵌入式变量标志。

尝试:

"some/path#{SVN_VERSION}"
于 2013-09-16T14:30:45.103 回答