Error when executing ruby ​​script
O.A.O.A
O.A.O.A 2018-10-09 16:22:31
0
0
1426

/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 can be executed normally in the terminal, but this error is prompted when the Jenkins page executes the shell. The ruby ​​code is as follows:

#!/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


O.A.O.A
O.A.O.A

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template