GitHub操作:在Windows环境C:\:\\Users\runneradmin\\.m2\repos



作为文档状态,为了用GitHub Actions缓存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-2016GitHub Actions环境,这并不能为我们提供工作缓存——正如日志所述:

Post job cleanup.
"C:Program FilesGitusrbintar.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:\Usersrunneradmin\.m2repository: 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 FilesGitusrbintar.exe' failed with exit code 2

如何解决此问题?

Maven存储库的路径似乎没有正确初始化。正如本期所述,路径是用\编写的,而不是GNU tar所期望的/。该修复程序已于2020年12月提供,因此它的版本为v2.1.4v2.1.3的最后一个版本于11月发布。但遗憾的是,在将v2指向最新的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

现在它应该像一个符咒一样工作(请参阅此处的日志(。

相关内容

最新更新