英文:
Failed to execute goal maven-antrun-plugin - Connection timed out on GitHub Actions
问题
以下是翻译好的内容:
我正在开发一个使用 Spring Boot + React/TypeScript 的应用程序,使用 GitHub Actions 进行持续集成和持续部署(CI/CD)。我最近添加了 react-app-rewired 包,以在不弹出 CRA 应用的情况下配置一些 webpack 设置。一切在本地构建和运行都很好(尽管速度稍慢),但是当推送到 GitHub 后,./mvnw test
命令在20多分钟后失败,并显示以下错误:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20:33 min
[INFO] Finished at: 2020-10-14T16:15:52Z
[INFO] ------------------------------------------------------------------------
Error: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project main: Execution default of goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.8 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-antrun-plugin:jar:1.8 -> org.apache.maven:maven-plugin-api:jar:2.2.1: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.2.1: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.2.1 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.pom: Connection timed out (Read failed) -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Error: Process completed with exit code 1.
这是我们使用的 GitHub Actions 的 workflow.yml
文件:
name: Java CI/CD
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
env:
JASYPT_ENCRYPTOR_PASSWORD: ${{secrets.JASYPT_ENCRYPTOR_PASSWORD}}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: ./mvnw test
deploy:
needs: test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
env:
JASYPT_ENCRYPTOR_PASSWORD: ${{secrets.JASYPT_ENCRYPTOR_PASSWORD}}
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.4.6
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "rocketden"
heroku_email: "email@gmail.com"
这是我们的 pom.xml
文件:
<!-- 详细内容见原文 -->
这是我们的 package.json
文件:
<!-- 详细内容见原文 -->
如果需要进一步帮助或指导,将不胜感激。
英文:
I'm working on a Spring Boot + React/TypeScript app which uses GitHub Actions for CI/CD. I recently added the react-app-rewired package to configure some webpack settings without ejecting our CRA app. Everything builds and runs fine locally (albeit a bit slower), but when pushed to GitHub, the ./mvnw test
command fails after 20+ minutes with the following error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20:33 min
[INFO] Finished at: 2020-10-14T16:15:52Z
[INFO] ------------------------------------------------------------------------
Error: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project main: Execution default of goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.8 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-antrun-plugin:jar:1.8 -> org.apache.maven:maven-plugin-api:jar:2.2.1: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.2.1: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.2.1 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.2.1/maven-plugin-api-2.2.1.pom: Connection timed out (Read failed) -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Error: Process completed with exit code 1.
This is the GitHub Actions workflow.yml
file we're using:
name: Java CI/CD
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
env:
JASYPT_ENCRYPTOR_PASSWORD: ${{secrets.JASYPT_ENCRYPTOR_PASSWORD}}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Maven
run: ./mvnw test
deploy:
needs: test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
env:
JASYPT_ENCRYPTOR_PASSWORD: ${{secrets.JASYPT_ENCRYPTOR_PASSWORD}}
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.4.6
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "rocketden"
heroku_email: "email@gmail.com"
Here is our pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.rocketden</groupId>
<artifactId>main</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>main</name>
<description>Our description</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<!-- WebSocket, STOMP, SockJS dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator-core</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>sockjs-client</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>stomp-websocket</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.1-1</version>
</dependency>
<!-- Basic Spring framework dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Enable ability to add Entity, Id, GeneratedValue tags -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- exclude tomcat jdbc connection pool, use HikariCP -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MySQL database -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Lombok dependency to use Getters, Setters -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Encryption for database configuration -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Logging dependency for testing -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- H2 database for testing -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- Gson, convert Java objects to JSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<!-- Hikari Connection Pool -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.4.5</version>
</dependency>
<!-- JUnit testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<!-- Model Mapper used to convert between DTOs and Entities -->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>frontend</workingDirectory>
<installDirectory>target</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v14.8.0</nodeVersion>
<npmVersion>6.14.8</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<target>
<copy todir="${project.build.directory}/classes/public">
<fileset dir="${project.basedir}/frontend/build" />
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And here is our package.json
file:
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@stomp/stompjs": "^5.4.4",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-router-dom": "^5.1.5",
"@types/react-splitter-layout": "^3.0.0",
"@types/sockjs-client": "^1.1.1",
"@types/stompjs": "^2.3.4",
"@types/styled-components": "^5.1.2",
"axios": "^0.20.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-monaco-editor": "^0.40.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-splitter-layout": "^4.0.0",
"sockjs-client": "^1.5.0",
"stompjs": "^2.3.3",
"styled-components": "^5.1.1",
"typeface-roboto": "0.0.75",
"typescript": "~3.7.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^2.5.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8080",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Any help or guidance would be much appreciated.
答案1
得分: 1
对于下一个遇到这个问题的人 - 这基本上只是Azure SNAT和Maven交互的问题。Maven在内部池化连接,而Azure的SNAT以Java很难察觉的方式关闭这些连接,而且由于GitHub归Microsoft所有,GitHub Actions在Azure中运行。
无论如何 - 当前Maven版本的修复方法是设置一个Maven参数来降低连接池中的TTL。如果您需要使用较旧的版本,还有一些其他参数可以使用。
因此,我在工作流程中添加了一个环境变量:
MAVEN_OPTS: '-Dmaven.wagon.httpconnectionManager.ttlSeconds=120'
另请参阅:
- 配置Maven,如果您不想使用MAVEN_OPTS
- WAGON-545 和 WAGON-486,如果您想获取有关此问题的更多信息
- 有关GH方面的更多信息,请参阅GH Actions虚拟环境#1499。
英文:
For the next person who runs into this -- this is basically just an issue with Azure SNAT and Maven interacting. Maven internally pools connections and Azure's SNAT closes them in a way that Java kinda can't see, and Github Actions (since GitHub is owned by Microsoft) runs in Azure.
Anyway -- the fix with current Maven versions is to set a Maven parameter to dial down the TTL on the connection pool. If you need to use an older version, there are some other parameters you can use.
So I added an env var to my workflow:
MAVEN_OPTS: '-Dmaven.wagon.httpconnectionManager.ttlSeconds=120'
See also:
- Configuring Maven if you don't want to use MAVEN_OPTS
- WAGON-545 and WAGON-486 if you want more information about the issue
- GH Actions Virtual Environments #1499 for a bit more on the GH side of things
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论