Builds run as the ubuntu
user by default, if you try to append /etc/apt/sources.list
using a method like echo it will fail with permission denied even if you use sudo since the redirection needs to be run as root as well. The simplest way to do this would be to run the command in a root subshell like this:
sudo sh -c 'echo "$REPO_NAME" >> /etc/apt/sources.list'