在尝试运行GitLab管道时,我得到了一个错误
"Error: Could not find or load main class Testing\GitLab-Runner\builds\EgKZ847y\0\sandeshmms\LearningSelenium..m2.repository"
同时,它也发出了这样的信息:
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
下面的是控制台消息:
Running with gitlab-runner 14.2.0 (58ba2b95)
on my-runner1 EgKZ847y
Preparing the "shell" executor 00:00
Using Shell executor...
Preparing environment
Running on HOMEPC...
Getting source from Git repository 00:10
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in D:/Java Testing/GitLab-Runner/builds/EgKZ847y/0/sandeshmms/LearningSelenium/.git/
Checking out 41ee697d as develop...
git-lfs/2.12.1 (GitHub; windows 386; go 1.14.10; git 85b28e06)
Skipping Git submodules setup
Restoring cache 00:02
Version: 14.2.0
Git revision: 58ba2b95
Git branch: 14-2-stable
GO version: go1.13.8
Built: 2021-08-22T19:47:56+0000
OS/Arch: windows/386
Checking cache for default-14...
Runtime platform arch=386 os=windows pid=5420 revision=58ba2b95 version=14.2.0
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
Successfully extracted cache
Executing "step_script" stage of the job script 00:03
$ echo "Testing Job Triggered"
Testing Job Triggered
$ echo $CI_PROJECT_DIR
D:\Java Testing\GitLab-Runner\builds\EgKZ847y\0\sandeshmms\LearningSelenium
$ mvn $MAVEN_OPTS clean test
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Error: Could not find or load main class Testing\GitLab-Runner\builds\EgKZ847y\0\sandeshmms\LearningSelenium..m2.repository
Uploading artifacts for failed job 00:02
Version: 14.2.0
Git revision: 58ba2b95
Git branch: 14-2-stable
GO version: go1.13.8
Built: 2021-08-22T19:47:56+0000
OS/Arch: windows/386
Uploading artifacts...
Runtime platform arch=386 os=windows pid=4312 revision=58ba2b95 version=14.2.0
WARNING: target/surefire-reports/*: no matching files
ERROR: No files to upload
Cleaning up file based variables 00:01
ERROR: Job failed: exit status 1
下面是完整的yaml文件:
stages:
- test
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
test job:
stage: test
tags:
- testing
script:
- echo "Testing Job Triggered"
- echo $CI_PROJECT_DIR
- 'mvn $MAVEN_OPTS clean test'
- echo "Testing Job Finished"
artifacts:
when: always
paths:
- target/surefire-reports/*
但是,如果我从yaml文件中删除变量部分和缓存部分,如果我只进行mvn干净测试,则构建运行良好。
另外,它正在将maven存储库下载到'C:\Windows\System32\config\systemprofile\.m2\repository'
。它为什么要下载到这个目录呢?
有人能帮忙吗?
发布于 2021-09-13 09:44:42
消息No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
只是意味着您的GitLab实例没有配置为使用AWS S3或Min.io之类的服务来存储缓存的项。没有它,缓存只能在运行Gitlab运行的本地存储。这也意味着存储在一个运行程序上的缓存不能与另一个运行程序共享,这很可能是如何遇到您所拥有的错误的。您也没有key
,因此运行程序不知道何时下载哪些cached
项目。
下面是一个构建NPM依赖项的作业示例,该依赖项使用缓存和特定引用名(分支、提交或标记)的键:
...
Run NPM Install:
stage: build
cache:
key: $CI_COMMIT_REF_NAME
paths:
- node_modules
script:
- npm ci
artifacts:
paths:
- node_modules
...
在这个作业中,对于CI_COMMIT_REF_NAME
下的分支、提交或标记的第一个管道,它将运行npm ci
并将其作为工件上传到稍后的管道中供作业使用。但是,如果同一分支、提交或标记的管道再次运行,它将下载缓存的npm ci
目录,而不是运行node_modules
,并将其作为工件上载。
有关缓存的更多信息,请参见GitLab CI/CD中的缓存,有关使用S3或Minio在所有运行程序中分发缓存的信息,请参见分布式缓存。
https://stackoverflow.com/questions/69159690
复制