2013-04-17 61 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如果沒有檢測到變化。因此,您始終可以輪詢回購的頂層以檢入,以觸發構建。如果有問題的文件發生變化,只需完成一次構建。

相關問題