Push failure to an empty Repo using GitPython

I have a Jenkins job that uses a python script (GitPython) to create a new repo. After upgrading Bitbucket from v4 to v7.21.3, the push to origin is not working. The Git version we are using is 2.22.
After creating an empty repo and adding an initial commit ( with an empty file), the push to master, generates this error:
WARNING: Error lines received while fetching: error: failed to push some refs to ‘ssh://git@bitbucket-test.idanalytics.com/engprod/test-v103.git’
However I am able to push with no issue under the workspace directory. I am able to see the initial log in the local repo and everything seems okay, only the python push call is not working. I have tried different ways of pushing, but it seems is not recognizing the initial commit and getting different errors.
Any suggestion would be appreciated.

Here is the code snippet:
def create_rep(project_key, repo_slug , gitignore_src, jira_id, dirs=None):

current_dir = os.getcwd()
repo_dir = current_dir + '/' + repo_slug
commit_msg = jira_id + ': creating new repository'
assert origin.exists()
assert origin == r.remotes.origin == r.remotes['origin']

# add gitignore file
if gitignore_src != None:
    shutil.copyfile(gitignore_src,repo_dir + '/.gitignore')