[英]How to use a set of jar files in classpath in Jenkins
How to make this possible ?如何使这成为可能?
I had a set of jar files which are to be included to CLASSPATH variable.我有一组要包含在 CLASSPATH 变量中的 jar 文件。
I don't want to give the command SET CLASSPATH=xxx.jar;xx.jar;..
as part of the build step.我不想将命令SET CLASSPATH=xxx.jar;xx.jar;..
作为构建步骤的一部分。
I dont' want to manually set the Environment variable CLASSPATH as part of system properties.我不想手动设置环境变量 CLASSPATH 作为系统属性的一部分。
I tried by copying a set of jar files into Jenkins_HOME/war/WEB-INF/lib
and had started the Jenkins server.我尝试将一组 jar 文件复制到Jenkins_HOME/war/WEB-INF/lib
并启动了 Jenkins 服务器。 But couldn't make it possible... Any Solution ?但不能让它成为可能......任何解决方案?
You can try by additional class-path elements maven.您可以尝试通过附加的类路径元素 maven。 you can see the details in below link https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html您可以在以下链接中查看详细信息https://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
<additionalClasspathElement>path/to/additional/jar</additionalClasspathElement>
<additionalClasspathElement>path/to/csv/jar1, path/to/csv/jar2</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
Set CLASSPATH environment as follows and any jar file updated it particular directory如下设置 CLASSPATH 环境,任何 jar 文件都会更新它的特定目录
SET CLASSPATH= <your_lib_directory>\\*
SET CLASSPATH= <your_lib_directory>\\*
This will pick up all the updated JAR files这将选取所有更新的 JAR 文件
I think you are making things harder on yourself than needs be.我认为你让自己变得比需要的更难。 Why don't you want to set the classpath as a pre-build step?为什么不想将类路径设置为预构建步骤? Perhaps because the artifacts change regularly?也许是因为文物定期更换?
My suggestion is that you look into building with Maven and convert your Jenkins job to a Maven job - then you can handle your extra dependencies in the POM and not in Jenkins - which may be a little more elegant.我的建议是您考虑使用Maven进行构建并将您的 Jenkins 作业转换为 Maven 作业 - 然后您可以在 POM 中而不是在 Jenkins 中处理您的额外依赖项 - 这可能更优雅一些。
For example, your JUnit and Selenium dependencies could be included as例如,您的 JUnit 和 Selenium 依赖项可以包含为
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
... etc
(the <scope>
being important to keep them out of your final artifact) and in the Jenkins job configuration, "Goals and options" could be test package
. ( <scope>
对于将它们排除在最终工件之外很重要)并且在 Jenkins 作业配置中,“目标和选项”可以是test package
。
Hope that helps.希望有帮助。
Cheers,干杯,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.