0

How to read all the files with a different extension (say .txt, .yml, etc) from the GitLab repository?

I'm using GitLabApi and below is the code that I have done so far. This is basically fetching a single file.

public class GitLabRepoService { @Value("${gitlab.accessToken}") private String strAccessToken; @Value("${gitlab.perfScript.projectId}") private String strProjectId; public RepositoryFile readFilesFromGitLabRepo(String hostUrl,String fileName,String strBranch) throws Exception { GitLabApi gitLabApi = new GitLabApi(hostUrl, strAccessToken); gitLabApi.setIgnoreCertificateErrors(true); gitLabApi.getRepositoryFileApi(). return gitLabApi.getRepositoryFileApi().getFile(strProjectId, fileName, strBranch); } } 
1
  • I need to get a complete file list of ALL files in the repository, not just the ones in the root directory. Commented Feb 26, 2020 at 8:38

1 Answer 1

2

What you want to request is the repositories tree if I understand correctly. For that you should use this endpoint https://docs.gitlab.com/ee/api/repositories.html

I could not properly test it but according to the docs it looks like RepositoryApi.getTree() is what you are looking for getTree()

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. yes I was looking for this

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.