首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GitHub操作:如何修复mvn:命令找不到nektos/act的问题

GitHub操作:如何修复mvn:命令找不到nektos/act的问题
EN

Stack Overflow用户
提问于 2022-12-03 11:22:57
回答 1查看 19关注 0票数 1

引言

我目前正在为一个GitHub项目做出贡献。

为此,我将在一个测试创建GitHub文件的GitHub操作中编写一个JavaDoc工作流。

这个工作流应该与演戏一起运行。

当我想添加这个GitHub工作流时,GitHub操作的项目:https://github.com/MathieuSoysal/Javadoc-publisher.yml

问题

问题是,当我使用act执行我的GitHub工作流时,我会得到这个错误。

代码语言:javascript
复制
[Test Actions/Test with Java 11]   Start image=catthehacker/ubuntu:act-latest
[Test Actions/Test with Java 11]     docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=false
[Test Actions/Test with Java 11]     docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test Actions/Test with Java 11]     docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test Actions/Test with Java 11]   ☁  git clone 'https://github.com/GuillaumeFalourd/assert-command-line-output' # ref=v2
[Test Actions/Test with Java 11] ⭐ Run Pre GuillaumeFalourd/assert-command-line-output@v2
[Test Actions/Test with Java 11]   ☁  git clone 'https://github.com/actions/setup-node' # ref=v2
[Test Actions/Test with Java 11]   ✅  Success - Pre GuillaumeFalourd/assert-command-line-output@v2
[Test Actions/Test with Java 11] ⭐ Run Main actions/checkout@v3
[Test Actions/Test with Java 11]     docker cp src=/workspaces/Javadoc-publisher.yml/. dst=/workspaces/Javadoc-publisher.yml
[Test Actions/Test with Java 11]   ✅  Success - Main actions/checkout@v3
[Test Actions/Test with Java 11] ⭐ Run Main ./
[Test Actions/Test with Java 11] ⭐ Run Main actions/checkout@v3
[Test Actions/Test with Java 11]     docker cp src=/workspaces/Javadoc-publisher.yml/. dst=/workspaces/Javadoc-publisher.yml
[Test Actions/Test with Java 11]   ✅  Success - Main actions/checkout@v3
[Test Actions/Test with Java 11]   ☁  git clone 'https://github.com/actions/setup-java' # ref=v3
[Test Actions/Test with Java 11] ⭐ Run Main actions/setup-java@v3
[Test Actions/Test with Java 11]     docker cp src=/home/codespace/.cache/act/actions-setup-java@v3/ dst=/var/run/act/actions/actions-setup-java@v3/
[Test Actions/Test with Java 11]     docker exec cmd=[node /var/run/act/actions/actions-setup-java@v3/dist/setup/index.js] user= workdir=
[Test Actions/Test with Java 11]   ❓  ::group::Installed distributions
| Trying to resolve the latest version from remote
| Resolved latest version as 11.0.17+8
| Trying to download...
| Downloading Java 11.0.17+8 (Adopt-Hotspot) from https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.17%2B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.17_8.tar.gz ...
[Test Actions/Test with Java 11]     ::debug::Downloading https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.17%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.17_8.tar.gz
[Test Actions/Test with Java 11]     ::debug::Destination /tmp/8533ad34-250e-4794-b6bd-f014648ce8b2
[Test Actions/Test with Java 11]     ::debug::download complete
| Extracting Java archive...
[Test Actions/Test with Java 11]     ::debug::Checking tar --version
[Test Actions/Test with Java 11]     ::debug::tar (GNU tar) 1.30%0ACopyright (C) 2017 Free Software Foundation, Inc.%0ALicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.%0AThis is free software: you are free to change and redistribute it.%0AThere is NO WARRANTY, to the extent permitted by law.%0A%0AWritten by John Gilmore and Jay Fenlason.
| [command]/usr/bin/tar xz --warning=no-unknown-keyword -C /tmp/4f3b749d-13d5-497d-87d7-45e30a9927cc -f /tmp/8533ad34-250e-4794-b6bd-f014648ce8b2
[Test Actions/Test with Java 11]     ::debug::Caching tool Java_Adopt_jdk 11.0.17-8 x64
[Test Actions/Test with Java 11]     ::debug::source dir: /tmp/4f3b749d-13d5-497d-87d7-45e30a9927cc/jdk-11.0.17+8
[Test Actions/Test with Java 11]     ::debug::destination /opt/hostedtoolcache/Java_Adopt_jdk/11.0.17-8/x64
[Test Actions/Test with Java 11]     ::debug::finished caching tool
| Java 11.0.17+8 was downloaded
| Setting Java 11.0.17+8 as the default
| Creating toolchains.xml for JDK version 11 from adopt
| Writing to /root/.m2/toolchains.xml
| 
| Java configuration:
|   Distribution: adopt
|   Version: 11.0.17+8
|   Path: /opt/hostedtoolcache/Java_Adopt_jdk/11.0.17-8/x64
| 
[Test Actions/Test with Java 11]   ❓  ::endgroup::
[Test Actions/Test with Java 11]   ❓  ##[add-matcher]/run/act/actions/actions-setup-java@v3/.github/java.json
| Creating settings.xml with server-id: github
| Writing to /root/.m2/settings.xml
[Test Actions/Test with Java 11]   ✅  Success - Main actions/setup-java@v3
[Test Actions/Test with Java 11]   ⚙  ::set-output:: distribution=Adopt-Hotspot
[Test Actions/Test with Java 11]   ⚙  ::set-output:: path=/opt/hostedtoolcache/Java_Adopt_jdk/11.0.17-8/x64
[Test Actions/Test with Java 11]   ⚙  ::set-output:: version=11.0.17+8
[Test Actions/Test with Java 11] ⭐ Run Main Generate Javadoc
[Test Actions/Test with Java 11]     docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1-composite-2.sh] user= workdir=
| /var/run/act/workflow/1-composite-2.sh: line 2: mvn: command not found
[Test Actions/Test with Java 11]   ❌  Failure - Main Generate Javadoc
[Test Actions/Test with Java 11] exitcode '127': command not found, please refer to https://github.com/nektos/act/issues/107 for more information
[Test Actions/Test with Java 11]   ☁  git clone 'https://github.com/JamesIves/github-pages-deploy-action' # ref=v4.4.0
[Test Actions/Test with Java 11]   ❌  Failure - Main ./
[Test Actions/Test with Java 11] exitcode '127': command not found, please refer to https://github.com/nektos/act/issues/107 for more information
[Test Actions/Test with Java 11] ⭐ Run Post ./
[Test Actions/Test with Java 11] ⭐ Run Post actions/setup-java@v3
[Test Actions/Test with Java 11]     docker exec cmd=[node /var/run/act/actions/actions-setup-java@v3/dist/cleanup/index.js] user= workdir=
[Test Actions/Test with Java 11]   ✅  Success - Post actions/setup-java@v3
[Test Actions/Test with Java 11]   ✅  Success - Post ./
[Test Actions/Test with Java 11]   Job failed

GitHub工作流

我的GitHub工作流:

代码语言:javascript
复制
name: Test Actions

on: [pull_request, push]

jobs:
  test:
    runs-on: ubuntu-latest
    
    name: Test with Java 11
    steps:
      - uses: actions/checkout@v3
      - uses: ./ # Uses an action in the root directory
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          javadoc-branch: javadoc-test
          java-version: 11
          target-folder: javadoc

      - uses: GuillaumeFalourd/assert-command-line-output@v2
        with:
          command_line: ls -lha
          contains: javadoc
          expected_result: PASSED

GitHub Action

项目的GitHub操作:https://github.com/MathieuSoysal/Javadoc-publisher.yml/blob/main/action.yml

命令

运行nektos/act的已执行命令:act

问题

有人知道如何用mvn: command not found issue来解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-12-03 11:41:15

解释

您的问题是与nektos/act一起使用的映像没有mvn造成的。

如何修复它

你有几种可能来解决这个问题。

第一解

第一个解决方案:如果你想保持你的形象。

您可以在GitHub工作流中添加以下行以添加mvn:

代码语言:javascript
复制
#### This step is only needed for GHA local runner, act:
# https://github.com/nektos/act
      - name: Install curl (for nektos/act local CI testing)
        run: apt-get update && apt-get install build-essential curl pkg-config openssl -y
      - name: Download Maven
        run: |
          curl -sL https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip -o maven.zip
          apt-get update
          apt-get -y install unzip
          unzip -d /usr/share maven.zip
          rm maven.zip
          ln -s /usr/share/apache-maven-3.6.3/bin/mvn /usr/bin/mvn
          echo "M2_HOME=/usr/share/apache-maven-3.6.3" | tee -a /etc/environment
####

第二解

第二个解决方案:如果你同意改变你的旧形象。

您可以执行以下命令,而不是act命令:

代码语言:javascript
复制
act -P ubuntu-latest=quay.io/jamezp/act-maven
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74666249

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档