Gitlab Test

A simple example of how to create a repository in gitlab with the master and develop branch, reactive programming is used with spring webflux, spring cloud contract both to generate the stubs and to consume them as well.

A little about the code

You must first create the repository and with the id returned from gitlab you invoke another endpoint to create the develop branch, i.e. both invocations to these services are merged with WebClient.

The Image 1

To create the image-1 at the moment the Dockerfile is executed from the image-1 folder, possibly with docker-compose the creation would be easier.

docker build -t image-1 .
docker run --rm -p 8080:8080 --network developers image-1

The openapi code gen generator is used to create the swagger and the endpoint.

swagger image1

Execute the post

This is the endpoint or entrypoint to create the repository, we pass it a this body either from a tool such as postman or from swagger itself

localhost:8080/api/v1/gitlab-repository
{
  "name": "test",
  "description": "Example of project creation using gitlab api with java.",
  "path": "basic_project",
  "initialize_with_readme": "true",
  "visibility": "public",
  "default_branch": "master"
}

The generated id is shown here

repository successfully created

new gitlab repo

Important

Important
If the repository is created in gitlab and we try to create it, we will get a BAD_REQUEST 400