Gitlab CI/CD runner : mvn command not found

前端 未结 4 1909
借酒劲吻你
借酒劲吻你 2021-01-06 06:17

Maven is well installed on my gitlab-runner server. When executing mvn clean directly on my repo it works, when running my pip

相关标签:
4条回答
  • 2021-01-06 06:37

    I hope you had figure out your question. I met the same question when I build my ci on my server.

    I use the shell as the executer for my Runner. here are the steps to figure out.

    1 check the user on the runner server

    if you had install maven on the runner server successfully, maybe it just successful for the root, u can check the real user for the ci process.

    job1:
      stage: test
      script:  whoami
    

    if my case, it print gitlab-runner, not the root

    2 su the real user, check mvn again

    In this time, it print error as same as the Gitlab ci UI.

    3 install maven for the real user. run the pipeline again.

    0 讨论(0)
  • 2021-01-06 06:44

    Add maven to PATH:

    $ export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
    
    $ export M2=$M2_HOME/bin
    
    $ export PATH=$M2:$PATH 
    

    You can include these commands in $HOME/.bashrc

    0 讨论(0)
  • 2021-01-06 06:49

    Just add the maven docker image, add below line as first line:

    image: maven:latest or image: maven:3-jdk-10 or image: maven:3-jdk-9
    

    refer: https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab/

    0 讨论(0)
  • 2021-01-06 06:50

    I managed to fix the problem using this workaround:

      script:
        - $MAVEN_HOME/bin/mvn clean
    
    0 讨论(0)
提交回复
热议问题