During the development process, the infrastructure or development professional may find it necessary to perform a search throughout the Gitlab repository. When our repository has a significant amount of projects, performing this search manually is not very productive and can bring a high margin of error.
The Gitlab in its opensource version has limited search functionality, but through the Gitlab4J library, we can perform more complex searches and other features of Gitlab.
Initially I used the python-gitlab library which I found fantastic, because it solved my pain of being searching the entire repository for certain information to generate a report.
As the months went by, my research got more complex and python-gitlab started not meeting my needs, so I decided to create a research library on Gitlab4J.
So I created the Scopre Repository for Gitlab, an open source product that can be useful to other professionals who need to conduct research in the Gitlab repository.
To run Scopre Repository, you must run it via command line using the parameters below:
java -jar ./target/scopre-repository-1.0-jar-with-dependencies.jar
-d
-t glpat-x2UHy2PSS7_AGRwKqUDu
-p 4
-f pom.xml
-s jasper
-b master
-h https://gitlab.com`
java -jar ./target/scopre-repository-1.0-jar-with-dependencies.jar
-d
-t glpat-x2UHy2PSS7_AGRwKqUDu
-p 4
-f ^.*.java$
-s "String" "Integer"
-b master
-h https://gitlab.com
report-yyyy-MM-dd hh-mm-ss.csv file generated with the search result.
report-yyyy-MM-dd hh-mm-ss.txt file generated with the search result.
We can take advantage of the search result, and use the result to filter a new search using the -i parameter, passing a list of found projects. This may be necessary sometimes if it is a search based on a flow that depends on the previous result, allowing to reduce the complexity and consequently the search time.
java -jar ./target/scopre-repository-1.0-jar-with-dependencies.jar
-d
-t glpat-x2UHy2PSS7_AGRwKqUDu
-p 4
-f ^.*.java$
-s "String" "Integer"
-b master
-h https://gitlab.com
-i inputfile.csv
We can use a plugin to perform actions when finding an instance of the search rule:
java -jar ./target/scopre-repository-1.0-jar-with-dependencies.jar
-d
-t glpat-x2UHy2PSS7_AGRwKqUDu
-p 4
-f ^.*.java$
-s "String" "Inteiro"
-b "master"
-h https://gitlab.com
-c plugin.gafawork.scopre.repository.SystemOutPlugin
Note: for the development of a plugin must be created a class based on ExecutePluging that should implement the method run:
package gafawork.scopre.repository.plugin;
public class SystemOutPlugin extends ExecutePlugin {
@Override
public void run() {
String msg = "<Execute Plugin>\n Project: " + getProjectName() + "\n"
+ " Branch: " + getBranchName()
+ " \n Path: " + getPath()
+ "\n Url: " + getUrl()
+ "\n Rule: " + getRule();
logger.info(msg);
}
}
In my next post, I will publish a specification for discovery APIs in the GitLab repository, using the Scopre Gitlab Repository.
Top comments (0)