如何在jenkins中替换自定义脚本?

时间:2012-07-26 17:22:32

标签: maven jenkins pom.xml

我正在使用jenkins构建maven应用程序,该项目旨在运行.jar文件。它目前生成一个.tar,它有一个以应用程序名称命名的shell文件。

我想知道是否可以替换自定义脚本生成的脚本。目前我可以实现的是将脚本包含在tar文件中:

 <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/maven-v4_0_0.xsd">

    <parent>
        <artifactId>org-pom</artifactId>
        <groupId>com.myOrg.org</groupId>
        <version>1.14</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.myOrg.division.group</groupId>
    <artifactId>myCurrentApplication</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>My Application</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <programs>
                        <program>                           
                            <mainClass>com.myOrg.division.group.MyMainClass</mainClass>
                            <name>myApplication</name>
                        </program>
                    </programs>
                    <platforms>                     
                        <platform>unix</platform>
                    </platforms>
                    <binFileExtensions>
                        <unix>.sh</unix>
                    </binFileExtensions>
                </configuration>
                <executions>
                    <execution>
                        <id>appassembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>assemble</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>                 
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath> 
                            <mainClass>com.myOrg.division.group.MyMainClass</mainClass>
                        </manifest>
                    </archive>
                    <descriptors>
                        <descriptor>src/assemble/bin.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

bin.xml如下所示:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>bin</id>
  <formats>
    <format>tar</format>
  </formats>
  <baseDirectory>target/appassembler</baseDirectory>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>target/appassembler</directory>
      <outputDirectory>myApplication</outputDirectory>
      <fileMode>0755</fileMode>
      <directoryMode>0755</directoryMode>
    </fileSet>
    <fileSet>
      <directory>src/main</directory>
      <outputDirectory>myApplication</outputDirectory>
      <includes>
                <include>conf/**</include>
                <include>scripts/**</include>
      </includes>
    </fileSet>
  </fileSets>
</assembly>

但是,这只包括它们,而不是替换它们。是否可以将myCustomShell.sh而不是myApplicationShell.sh作为主脚本?

注意:我无法更改jenkins中的任何配置。

感谢。

0 个答案:

没有答案