An open API service indexing awesome lists of open source software.

https://github.com/terminal127/maven_simple_pipeline


https://github.com/terminal127/maven_simple_pipeline

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

# Java Maven Project CI/CD Pipeline

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:

1. **Build**: Compiles the code using Maven.

2. **Test**: Runs unit tests and performs code linting.

3. **Deploy**: Deploys the application (currently set to a staging environment).

## Pipeline Configuration

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.

### Environment Variables

- `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.

### Cache Configuration

Caching is set up to speed up the pipeline by storing the Maven repository dependencies.

### Stages and Jobs

- **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).

## Usage

1. Clone this repository to your local machine.

2. Modify the Java project in the `my-app` directory to suit your needs.

3. Configure the `.gitlab-ci.yml` file to match your project's structure and requirements.

4. Push your code to your GitLab repository.

5. The GitLab CI/CD pipeline will be automatically triggered, and you can monitor the progress in the GitLab interface.

6. After a successful pipeline run, the application will be deployed to the specified environment (staging in this case).

7. You can customize the deployment stage to suit your production environment requirements.

## Notes

- 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](https://docs.gitlab.com/ee/ci/)