As the docs state为了使用GitHub操作缓存Maven依赖项,我们只需使用如下所示的actions/cache操作:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify但是,使用windows-2016 GitHub Actions环境时,这并不能为我们提供工作缓存- as the logs states
Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" --posix --use-compress-program "zstd -T0" -cf cache.tzst -P -C D:/a/spring-boot-admin/spring-boot-admin --files-from manifest.txt --force-local
/usr/bin/tar: C\:\\Users\runneradmin\\.m2\repository: Cannot stat: No such file or directory
/usr/bin/tar: Exiting with failure status due to previous errors
Warning: Tar failed with error: The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2如何解决这个问题?
发布于 2021-03-30 19:17:23
指向Maven存储库的路径似乎未正确初始化。作为this issue describes,路径是用\\编写的,而不是GNU期望的/。The fix was already provided in Dec 2020,所以它被移植到了v2.1.4版本。最新版本的v2.1.3是在11月发布的。但遗憾的是,还有a bug in pointing the v2 to the latest v2.1.4 (正如GitHub Actions用户通常所期望的那样)。因此,为了解决这个问题,我们需要明确地指定完整的操作/缓存版本v2.1.4,如下所示:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2.1.4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify现在,它应该像一个护身符一样工作(see logs here)。
https://stackoverflow.com/questions/66870002
复制相似问题