Skip to content

gitlabci-java plugin

This plugin set up Gitlab Pipeline in an existing Gitlab Java repository.

Usage

Notes:

  1. This plugin requires a Java Gitlab repository first

  2. If Build is enabled (see the example below), you need to set DOCKERHUB_TOKEN environment variable. This will push the new built image to your repository(only support docker hub now).

  3. If Deploy is enabled, you need to offer the Gitlab Kubernetes agent name(see Gitlab-Kubernetes for more details). This will deploy the new built application to your Kubernetes cluster. This step will use deployment.yaml to automatically deploy the application. Please create manifests directory in the repository root and create your deployment.yaml configuration file in it.

YAML
tools:
# name of the tool
- name: gitlabci-java
  # id of the tool instance
  instanceID: default
  # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  dependsOn: [ ]
  # options for the plugin
  options:
    # Indicate the branch that the plugin will submit the workflows
    branch: main
    # owner/repo; "path with namespace" is only GitLab API's way of saying the same thing; please change the values below.
    pathWithNamespace: "YOUR_GITLAB_USERNAME/YOUR_GITLAB_REPO_NAME"
    baseURL:
    # Project package step, default use "maven"
    package:
      baseOption:
        # Set true to enable package function
        enable: True
        # The docker iamge used for packaging, default use "maven:3.6.2-jdk-14"
        image: "IMAGE_FOR_PACKAGE"
        # The Gitlab runner tag, you should set up a runner first, default use name "gitlab-java"
        tags: "YOUR_GITLAB_RUNNER_TAG"
        # Package step will run on the specified branchs, default use "main"
        allowedBranch:
          - "main"
          - "test"
      # Customized pipeline scripts. Leave it blank to use default value. 
      scriptCommand:
        - "YOUR_PACKAGE_SCRIPTS"
    build:
      # Same as above
      baseOption:
        enable: True
      registry:
        # DockerHub username
        username: "YOUR_DOCKERHUB_USERNAME"
      # Image name for building
      imageName: "YOUR_BUILD_IMAGE"
    deploy:
      # Same as above
      baseOption:
        enable: True
      # Gitlab-Kubernetes agent name
      k8sAgentName: "K8S_AGENT_NAME"