跳转至

gitlabci-java 插件

用例

注意:

  1. 使用该插件之前,需要在Gitlab上拥有一个Java代码仓库。

  2. 如果Build选项被开启,需要设置DOCKERHUB_TOKEN环境变量。这会将新构建的镜像推送到你的镜像仓库(目前只支持docker hub仓库)。

  3. 如果Deploy选项被开启,你需要提供Gitlab配置的Kubernetes代理名称(设置详情参照Gitlab-Kubernetes)。这会将新构建的应用部署至上面提供的Kubernetes集群中。该步骤会使用deployment.yaml来自动部署应用,请在仓库根目录下创建manifests目录,并在其中新建你的deployment.yaml配置文件。

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"