2013-04-17 39 views

回答

3

我还没有尝试过自己,但FSTrigger插件似乎做你想要什么:

FSTrigger提供轮询机制,以监视文件系统和 触发构建,如果一个文件或一组文件已改变。

如果你能监视与脚本的目录,你可以触发一个HTTP的GET构建,例如用wgetcurl

wget -O- $JENKINS_URL/job/JOBNAME/build 
1

虽然稍微相关..好像这个问题是关于监视系统上的静态文件..但是有很多版本控制系统只是为了这个目的。

我回答了这个在another post如果你使用git跟踪文件本身的变化:

#!/bin/bash 

set -e 

job_name="whatever" 
JOB_URL="http://myserver:8080/job/${job_name}/" 
FILTER_PATH="path/to/folder/to/monitor" 

python_func="import json, sys 
obj = json.loads(sys.stdin.read()) 
ch_list = obj['changeSet']['items'] 
_list = [ j['affectedPaths'] for j in ch_list ] 
for outer in _list: 
    for inner in outer: 
    print inner 
" 

_affected_files=`curl --silent ${JOB_URL}${BUILD_NUMBER}'/api/json' | python -c "$python_func"` 

if [ -z "`echo \"$_affected_files\" | grep \"${FILTER_PATH}\"`" ]; then 
    echo "[INFO] no changes detected in ${FILTER_PATH}" 
    exit 0 
else 
    echo "[INFO] changed files detected: " 
    for a_file in `echo "$_affected_files" | grep "${FILTER_PATH}"`; do 
    echo " $a_file" 
    done; 
fi; 

您可以将检查直接添加到工作的exec外壳的顶部,它会exit 0如果没有检测到变化。因此,您始终可以轮询回购的顶层以检入,以触发构建。如果有问题的文件发生变化,只需完成一次构建。

相关问题