I am trying to use python for my jenkins job, this job downloads and refreshes a line in the project then commits and creates a pull request, I am trying read the documentation for GitPython as hard as I can but my inferior brain is not able to make any sense out of it.
import git
import os
import os.path as osp
path = "banana-post/infrastructure/"
repo = git.Repo.clone_from('https://github.myproject.git',
osp.join('/Users/monkeyman/PycharmProjects/projectfolder/', 'monkey-post'), branch='banana-refresh')
os.chdir(path)
latest_banana = '123456'
input_file_name = "banana.yml"
output_file_name = "banana.yml"
with open(input_file_name, 'r') as f_in, open(output_file_name, 'w') as f_out:
for line in f_in:
if line.startswith("banana_version:"):
f_out.write("banana_version: {}".format(latest_banana))
f_out.write("\n")
else:
f_out.write(line)
os.remove("deploy.yml")
os.rename("deploy1.yml", "banana.yml")
files = repo.git.diff(None, name_only=True)
for f in files.split('\n'):
repo.git.add(f)
repo.git.commit('-m', 'This an Auto banana Refresh, contact [email protected]',
author='[email protected]')
After committing this change I am trying to push
this change and create a pull request
from branch='banana-refresh'
to branch='banana-integration'
.