作为Jenkins构建的一部分,Jenkins使用Maven,而Maven又在项目的根目录中使用了pom.xml文件。现在它几乎是一个无操作:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dqsalpha-dev.app</groupId>
<artifactId>dqsalpha</artifactId>
<version>1</version>
</project>
我想在这个pom文件中添加一个东西 - 我希望在maven build
运行时运行一个测试(它只是一个shell脚本)。
通过pom文件向Maven构建添加测试的最简单方法是什么?
这样的事情:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dqsalpha-dev.app</groupId>
<artifactId>dqsalpha</artifactId>
<version>1</version>
<test>
<bash>
@test.sh
</bash>
</test>
</project>
除了完全不正确。我只是意识到我也可能需要安装Node.js依赖项,使用npm install。
我试过了:
https://bitbucket.org/atlassian/bash-maven-plugin
然后我的pom.xml看起来像:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dqsalpha-dev.app</groupId>
<artifactId>dqsalpha</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>bash-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>test</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<script>
npm install;
./test.sh
</script>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<example.one>Variable replacement is available from Maven.</example.one>
</properties>
<dependencies>
<dependency>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>bash-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
然后我收到了这个错误:
$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building dqsalpha 1
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.atlassian.maven.plugins:bash-maven-plugin:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.187 s
[INFO] Finished at: 2017-04-11T16:09:24-07:00
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin com.atlassian.maven.plugins:bash-maven-plugin:1.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact com.atlassian.maven.plugins:bash-maven-plugin:jar:1.0-SNAPSHOT -> [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
答案 0 :(得分:2)
您可以使用exec-maven-plugin
:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>test1</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/test.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
答案 1 :(得分:1)
我只是意识到我可能还需要通过npm install安装Node.js依赖项。
如果您在 <link rel="stylesheet" href="{{ url_for('static', filename='css/blog_view.css') }}">
<script type="text/javascript" src="{{ url_for('static', filename='javascript/blogview.js') }}"></script>
中所做的是Node.js和npm的内容,则可以改用frontend-maven-plugin
,尽管它的名称是为了安装和运行Node.js和npm而设计的。这是一个示例,但是请参见https://github.com/eirslett/frontend-maven-plugin,以获取更多信息。
test.sh