美文网首页
gitlab-runner运行一直卡住

gitlab-runner运行一直卡住

作者: 冷小冰Q | 来源:发表于2021-09-26 18:24 被阅读0次

    在使用 gitlab-runner 搭建 CICD 过程中遇到一直卡住结束不了的问题。在此记录下问题。

    重现步骤

    • .gitlab-ci.yml
    variables:
      GIT_CLEAN_FLAGS: none                        # disable git clean
      SERVER_WORK_PATH: "/home/work/app/test"
    stages:
      - build
      - delivery
      - deploy
      - clean
    job_build:
      stage: build
      only:
        - master
      tags:
        - java
      script:
        - echo "---------------------------Begin to build---------------------------"
        - pwd
        - mvn clean package -DskipTests -T4 -Pdev -ff
        - echo "---------------------------End of the build---------------------------"
    job_delivery:
      stage: delivery
      tags:
        - java
      script:
        - echo "---------------------------Begin to delivery---------------------------"
        - mkdir -p $SERVER_WORK_PATH/test
        - cp $CI_PROJECT_DIR/test/target/test.jar    $SERVER_WORK_PATH/test
        - echo "---------------------------End of the delivery---------------------------"
    job_deploy:
      stage: deploy
      tags:
        - java
      script:
        - echo "---------------------------Begin to deploy---------------------------"
        - cd $SERVER_WORK_PATH
        - nohup java -jar test.jar >>$PROJECTDIR/nohup.out &
        - echo "---------------------------End of the deploy---------------------------"
    job_clean:
      stage: clean
      tags:
        - java
      script:
        - echo "---------------------------Begin to clean---------------------------"
        - cd $CI_PROJECT_DIR && mvn clean
        - echo "---------------------------End of the clean---------------------------"
    

    原因

    在启动 jar 时日志输出方式错误

    nohup java -jar test.jar >>$PROJECTDIR/nohup.out &
    

    正确方式

    nohup java -jar test.jar >>$PROJECTDIR/nohup.out 2>&1 &
    

    相关文章

      网友评论

          本文标题:gitlab-runner运行一直卡住

          本文链接:https://www.haomeiwen.com/subject/hpaqnltx.html