未能执行目标 maven-antrun-plugin - GitHub 操作上的连接超时
Posted
技术标签:
【中文标题】未能执行目标 maven-antrun-plugin - GitHub 操作上的连接超时【英文标题】:Failed to execute goal maven-antrun-plugin - Connection timed out on GitHub Actions 【发布时间】:2021-01-29 05:00:40 【问题描述】:我正在开发一个使用 GitHub Actions 进行 CI/CD 的 Spring Boot + React/TypeScript 应用程序。我最近添加了 react-app-rewired 包来配置一些 webpack 设置,而不会弹出我们的 CRA 应用程序。一切都在本地构建和运行良好(虽然有点慢),但是当推送到 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
:
<?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>
这是我们的package.json
文件:
"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"
]
任何帮助或指导将不胜感激。
【问题讨论】:
【参考方案1】:对于遇到此问题的下一个人 - 这基本上只是 Azure SNAT 和 Maven 交互的问题。 Maven 在内部汇集连接,Azure 的 SNAT 以 Java 看不到的方式关闭它们,Github Actions(因为 GitHub 归 Microsoft 所有)在 Azure 中运行。
无论如何——当前 Maven 版本的解决方法是设置一个 Maven 参数以拨低连接池上的 TTL。如果您需要使用旧版本,可以使用其他一些参数。
所以我在我的工作流程中添加了一个 env var:
MAVEN_OPTS: '-Dmaven.wagon.httpconnectionManager.ttlSeconds=120'
另见:
Configuring Maven 如果你不想使用 MAVEN_OPTS WAGON-545 和 WAGON-486 如果您想了解有关该问题的更多信息 GH Actions Virtual Environments #1499 了解更多关于 GH 方面的信息【讨论】:
以上是关于未能执行目标 maven-antrun-plugin - GitHub 操作上的连接超时的主要内容,如果未能解决你的问题,请参考以下文章
未能执行目标... maven-install-plugin ... 无法安装工件...(访问被拒绝)
未能执行目标 org.apache.maven.plugins:maven-enforcer-plugin
未能执行目标 maven-antrun-plugin - GitHub 操作上的连接超时
未能执行目标 org.apache.maven.plugins:maven-resources-plugin:2.5:resources
未能执行目标 org.springframework.boot:spring-boot-..:2.1.8。运行时发生异常。空值