这篇文章上次修改于 745 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

配置环境变量和流程stages

variables:
  BUILD_SHELL: "mvn clean package -Dmaven.test.skip=true -Dmaven.repo.local=/hadoop/.m2/repository --settings=/usr/local/apache-maven-3.8.7/conf/settings.xml -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true"
stages:          # List of stages for jobs, and their order of execution
  - build
  - deploy

build job配置

build-job:      
  stage: build
  tags:
    - hdp3
  script:
    - echo $CI_COMMIT_MESSAGE
    - echo `mvn --version`
    - echo $BUILD_SHELL
    - $BUILD_SHELL

部署job配置

deploy-job:      # This job runs in the deploy stage.
  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
  environment: production
  tags:
    - hdp3
  script: 
    - echo "Deploying application..."
    - sh /hadoop/target/restart.sh
    - echo "Application successfully deployed."