Jenkins脚本管道的自定义触发器

时间:2017-02-04 15:45:06

标签: jenkins jenkins-pipeline

我需要监视一个远程SFTP文件夹,以便触发我的Jenkins脚本管道。

我搜索过谷歌和詹金斯的文档,但我找不到在哪里插入将由Jenkins用来决定触发或不接受我的工作的自定义代码。

您知道是否可以或者我应该编写自定义插件吗?

1 个答案:

答案 0 :(得分:1)

我猜测推送触发构建是不可能的,你需要回到轮询。在这种情况下,我将创建第二个管道作业,监视远程SFTP文件夹。如果检测到更改,则会使用build步骤触发实际作业。有些东西:

node {
  def changes = false;
  // Do your monitoring of the SFTP server here and set changes to true if changes are detected. If you need a state between different runs of this job, then you can use the archive and copyArtifact step to save and retrieve state from last run.
  if (changes) {
    build job: 'A', propagate: false, wait: false
  }

然后将此作业设置为定期触发: Triggering periodically

相关问题