Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins 无法在文件脚本中使用变更集_Jenkins_Groovy - Fatal编程技术网

Jenkins 无法在文件脚本中使用变更集

Jenkins 无法在文件脚本中使用变更集,jenkins,groovy,Jenkins,Groovy,我的Jenkins文件脚本中的步骤有问题。我试图使用when changeset来确定特定文件集是否已更改,因为我只想在某些文件更改时生成。我添加此步骤是为了在文件更改时调用单独的构建作业 stage('File check') { when { changeset "**/files"} steps { build 'Build and deploy' }

我的Jenkins文件脚本中的步骤有问题。我试图使用when changeset来确定特定文件集是否已更改,因为我只想在某些文件更改时生成。我添加此步骤是为了在文件更改时调用单独的构建作业

        stage('File check') {
             when { changeset "**/files"}
             steps {
                  build 'Build and deploy'
             }
         }
然而,我得到了一个错误

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 5: Unknown conditional changeset. Valid conditionals are: allOf, anyOf, branch, environment, expression, not @ line 5, column 21.
                when { changeset "**/files"}

我错过了什么?我的Jenkins/groovy版本有问题吗?我在用詹金斯。2.73.3.

以下是对我有效的方法:

  String projectDirectory = "terraform"
  String changesetPathRegex = "**/${projectDirectory}/**"

    stage('Build Dockerfile') {
            when { changeset changesetPathRegex }
            steps {
                dir(projectDirectory) {
                    sh 'terraform plan'
                }
            }
        }

应该查看当前回购协议的“terraform”文件夹,如果发现有变化,就进行处理。

升级管道插件。