This repository contains a GitLab CI/CD configuration for a Java Maven project. The pipeline is set up to build, test, and deploy the project. It consists of the following stages:
-
Build: Compiles the code using Maven.
-
Test: Runs unit tests and performs code linting.
-
Deploy: Deploys the application (currently set to a staging environment).
The .gitlab-ci.yml
file in this repository is used to define the pipeline configuration. It specifies the jobs and their execution order, as well as some environment variables and caching settings.
MAVEN_CLI_OPTS
: Configures Maven with batch mode.MAVEN_OPTS
: Sets the Maven local repository directory to$CI_PROJECT_DIR/.m2/repository
for caching dependencies.
Caching is set up to speed up the pipeline by storing the Maven repository dependencies.
-
Build Stage:
build-job
: Compiles the code using Maven.
-
Test Stage:
unit-test-job
: Runs unit tests and collects test reports.lint-test-job
: Performs code linting.
-
Deploy Stage:
deploy-job
: Deploys the application (currently to a staging environment).
-
Clone this repository to your local machine.
-
Modify the Java project in the
my-app
directory to suit your needs. -
Configure the
.gitlab-ci.yml
file to match your project's structure and requirements. -
Push your code to your GitLab repository.
-
The GitLab CI/CD pipeline will be automatically triggered, and you can monitor the progress in the GitLab interface.
-
After a successful pipeline run, the application will be deployed to the specified environment (staging in this case).
-
You can customize the deployment stage to suit your production environment requirements.
-
Ensure that you have the necessary permissions and access to the GitLab repository.
-
If you encounter authentication issues, provide the correct GitLab credentials during the push to the remote repository.
-
Customize the pipeline stages and jobs as needed for your project.
-
Make sure to adapt the Maven commands, directories, and job scripts to match your specific project structure and requirements.
For more information on GitLab CI/CD, refer to the GitLab CI/CD documentation