/usr/local/lib/ruby/gems/2.1.0/gems/json-2.1.0/lib/json/common.rb:156:in `parse': 765: unexpected token at 'decode() argument 1 must be string, not None (JSON::ParserError)
在終端ruby xxx.rb可以正常執行,但是jenkins頁面執行shell時候提示這個錯誤。 ruby程式碼如下:
#!/usr/bin/env ruby
#require 'json'
cmd = "/usr/local/bin/aliyuncli ecs DescribeInstances -- output json --PageSize 50 --RegionId "
RegionIds = ["cn-hangzhou","cn-qingdao","cn-beijing","cn-hongkong","cn-shenzhen"," us-west-1"]
RegionIds.each do |regionid|
data = `#{cmd} #{regionid}`
# data = JSON.parse( data)
data["Instances"]["Instance"].each {|instance| print instance["RegionId"]," ",instance["InstanceName"]," ",instance["PublicIpAddress "]["IpAddress"][0]," ",instance["InnerIpAddress"]["IpAddress"][0],"\n"}
#puts data
#end