Using the Python module python-gitlab, project management can be done on a GitLab server without using the built-in GitLab WEB-GUI, directly. So, the git repository and wikis can programmatically be operated on.
Now, I have found a way to download, edit and upload wiki pages by using this code:
# connect to GitLab server
gl = gitlab.Gitlab(
<URL>,
private_token=<TOKEN>,
api_version=4,
ssl_verify=False
)
# get list of owned projects
lstProjects_owned = gl.projects.list(owned=True)
lstProjectNames_owned = []
for i in range(0, len(lstProjects_owned)):
lstProjectNames_owned.append(lstProjects_owned[i].name)
# get wiki page
idxProject = 0
slgWiki = 'home'
WikiPage = lstProjects_owned[idxProject].wikis.get(slgWiki)
But I have not found out (after reading various docs), how to upload a file which I can access by hyperlink from within a wiki page.
Does anybody know how to do this (preferrably with Python an the python-gitlab module)?
Here's what I have found:
You should use the gitlab api to interface with the project's wiki repository and upload the file that way. Look at how you can clone the wiki repository and also how to upload a file. Check the answer to this question for more information about the location to upload the file.
Then, simply edit the wiki page with the hyperlink to the uploaded file using the wiki APIs which you are already using in your example.
I do not use gitlab, or this API, but these links should get you started on solving your problem.