首页 > 解决方案 > 如何在 jenkins 中安装这些项目,以便只能在一个项目中提供该选项

问题描述

项目测试MV

我有项目TestMV,它依赖于项目TestMV1。

我已经在 jenkins 中分别部署了这些项目,并在目标和选项部分中传递参数,例如 install -Dversion=13.2.00,这也是在项目 TestMV1 配置中完成的。我想配置这个安装 -

Dversion=13.2.00 仅在项目 TestMV 中,这应该在项目中共享

詹金斯工作中的 TestMV1 也是。而且这也应该在eclipse中起作用。

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.TestMV</groupId>
  <artifactId>TestMV</artifactId>
  <version>${version}</version>
  <packaging>jar</packaging>

  <name>TestMV</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <version>13.2.00</version>
  </properties>
  <dependencies>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.TestMV1</groupId>
      <artifactId>TestMV1</artifactId>
      <version>${version}</version>
       </dependency>
  </dependencies>
</project>

项目测试MV1

<modelVersion>4.0.0</modelVersion>
  <groupId>com.TestMV1</groupId>
  <artifactId>TestMV1</artifactId>
  <version>${version}</version>
  <packaging>jar</packaging>
  <name>TestMV1</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <version>13.2.00</version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

在项目 TestMV 配置的目标部分中传递 install -dversion 时。

我们如何才能将 -dversion 传递给 jenkins 中的项目 b,而不是在 jenkins 中的项目 TestMV1 配置的目标部分中编写 install -dversion。

项目 TestMV 具有 TestMV1 的依赖项

标签: mavenjenkins

解决方案


我在 jenking 中创建了全局变量,并在目标和选项部分(如安装 -Dversion=${version})中传递了它。在两个 Maven 项目中完成。

问题解决了。谢谢


推荐阅读