小编Ale*_*lov的帖子

通过轮询Jenkinsfile中的多个GIT存储库来触发作业

具有两个git存储库Jenkinsfile中,这些是在单个Jenkins作业中使用多个GIT存储库的示例:

node {
    dir('RepoOne') {
        git url: 'https://github.com/somewhere/RepoOne.git'
    }
    dir('RepoTwo') {
        git url: 'https://github.com/somewhere/RepoTwo.git'
    }

    sh('. RepoOne/build.sh')
    sh('. RepoTwo/build.sh')
}
Run Code Online (Sandbox Code Playgroud)

如何配置此作业以跟踪这两个存储库的SCM更改,以便每次至少有一个存储库具有更新时触发该作业?

问题在于,作业不是轮询Jenkinsfile内提到的存储库,而是轮询Jenkinsfile本身的存储库(它存储在特殊的存储库中,而不是与源代码一起存储),这是在作业的GUI配置中提到的。

使用旧的Jenkins(无编码管道)和SVN插件,这非常容易,因为可以在GUI配置中提及所有N个存储库,将其检出到单个工作空间的单独子目录并同时进行轮询。

如何使用GIT + Jenkins Pipeline-As-Code获得相同的结果?我尝试在Jenkinsfile中也使用“ poll:true”选项,但没有帮助。那么此选项有什么作用?

更新1:这是我真正使用的管道脚本,但是它不起作用:

properties([
    pipelineTriggers([
        scm('H/5 * * * *')
    ])
])

node {
  stage ('Checkout') {
    dir('cplib') {
      git(
      poll: true,
          url: 'ssh://git@<server>:<port>/base/cplib.git',
          credentialsId: 'BlueOceanMsl',
          branch: 'master'
      )
    }
    dir('cpmffmeta') {
      git(
      poll: true,
          url: 'ssh://git@<server>:<port>/base/cpmffmeta.git',
          credentialsId: 'BlueOceanMsl',
          branch: 'master'
        )
    }
  }

  stage ('Build') {
    ...
  }
Run Code Online (Sandbox Code Playgroud)

git polling jenkins-pipeline

5
推荐指数
1
解决办法
6608
查看次数

maven antrun:如何迭代文件?

我在https://github.com/jjYBdx4IL/example-maven-project-setups/blob/master/antrun-foreach/pom.xml设置了一个示例:

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <phase>process-test-resources</phase>
                    <configuration>
                        <tasks>
                            <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
                            <foreach target="unzipLibs" param="fileName">
                                <path>
                                    <fileset dir="${basedir}" casesensitive="yes">
                                        <include name="*.xml"/>
                                    </fileset>
                                </path>
                            </foreach>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>ant-contrib</groupId>
                    <artifactId>ant-contrib</artifactId>
                    <version>1.0b3</version>
                    <!--                        <exclusions>
                        <exclusion>
                            <artifactId>ant</artifactId>
                            <groupId>ant</groupId>
                        </exclusion>
                    </exclusions>-->
                </dependency>
            </dependencies>
            <configuration>
                <target name="unzipLibs">
                    <echo message="${fileName}" />
                </target>
            </configuration>
        </plugin>            
Run Code Online (Sandbox Code Playgroud)

但是,无论我如何尝试,它都不起作用:

Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project antrun-foreach: Error executing ant tasks: org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg/apache/tools/ant/util/FileUtils; -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

或者,使用 ant 排除:

[ERROR] Failed to execute …
Run Code Online (Sandbox Code Playgroud)

java maven maven-antrun-plugin

3
推荐指数
1
解决办法
4281
查看次数