搭建就不說了,直接示例如何使用pipeline.
一、以下輸入參數:版本號為字符參數,按文檔更新的是文本參數。
二、腳本對更新內容的處理如下:
file_update_list="/home/www/html/yhzinclude.conf"
##接收傳遞過來的文件列表,處理不需要的字符后,存放到file_update_list文件
echo "$3" | grep -q '/trunk';if [ $? -ne 0 ];then echo "未找到trunk字段,請檢查待更新文件列表是否規范";exit 3;fi
echo "$3" | grep '/trunk' | awk -F '/trunk' '{print $2}' >> "$file_update_list"
##tg更新需要權限
chmod 777 $file_update_list
##流水線腳本如下( input部分可去掉,'Online'是自定義的,stage可多個):
pipeline {
agent {
label 'master' /* 執行節點 */
}
stages {
stage('Online') {
steps {
input "Are you sure to commit?"
sh "/bin/bash /data/shell/yhz_online_update.sh '$Comment' '$Version' '$Content'"
}
}
}
post {
always {
echo 'One way or another, I have finished'
deleteDir() /* clean up our workspace */
}
success {
echo 'I succeeeded!'
}
unstable {
echo 'I am unstable :/'
}
failure {
echo 'I failed :('
}
changed {
echo 'Things were different before...'
}
}
}
##官網參考:https://jenkins.io/doc/book/pipeline/