You may have already moved on from the issue at hand, but I wanted to post an example if it helps anyone in future. I faced the same issue when I wanted to set an environment variable called SERVER_PORT in my S2I scripts.
I put it in the assemble script, in the container file, it did not work. I managed to make it work when I put it in the .s2i/environment file.
My sample s2i scripts code can be found here : https://github.com/summu1985/s2i-test-httpd.git
Thanks!