Jenkins shows the job as failed if there is nothing to commit to gitlab
In order to get a success, you need to avoid non-zero exit codes. A simple solution would be to change the last line of your script to git commit -a -m 'Changes pushed by Jenkins' || true, but better solutions would parse the output of git-add and only run git-commit when there is something to commit.