I have a problem running a shell-script which basically commits changes within a directory to a remote git-repository from within another script. The "super-script" is being run with superuser-permissions, and I have the needed ssh-keys generated at ~/.ssh/ in my super user's home directory. Also, running the inner script standalone works fine and pushes to the remote repository.
This is the error I get when running the super-script:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 326 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to push code to protected branches on this project.
To git@url.goes.here:groupspace/projectspace.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@url.goes.here:groupspace/projectspace.git'
and I call the inner script with this line of code, saving its exit-status for further processing
SUCCESS = $(bash /path/to/push-config.sh)
This is the content of push-config.sh
#!/bin/bash
#
stamp=$(date +"%Y-%m-%d %T")
git add .
git commit -m "Config $stamp"
if [ $? -eq 0 ]
then
git push -u origin master
if [ $? -eq 0 ]
then
echo "Successfully pushed config to repo."
exit 0
else
echo "Failure while pushing to repo."
exit 1
fi
else
exit 1
fi
Any help appreciated, thanks in advance.