Providing input to a `gitlab-rails runner` script

I’m trying to automate doing something inside gitlab. I can do what I want from a gitlab-rails console, and from a script executed with gitlab-rails runner <script>. But what I need to do requires some input, which ways can be used to pass input to such a script? I think we’ve previously used environment variables, but when I try to access ENV["FOO"] in such a script I don’t get anything, see:

kitchen@gitlab:~$ cat /tmp/rrs.rb
foovar = ENV["FOO"]

puts "\n"
puts foovar
puts "\n"
kitchen@gitlab:~$ FOO=bar sudo gitlab-rails runner /tmp/rrs.rb


I can see two methods that might (I haven’t tried yet) work:

  1. Create the script dynamically so the input is actually in the script
  2. Put the input in a file and make the script open and read that

Can anyone say that I’m just doing something wrong in my attempt to use environment variables, or suggest other methods?