Jenkins 小姿势整理

2018-08-14  本文已影响0人  blaker

1. 接口调用触发构建:

调用方式:

1. 浏览器登录后访问 

http://${JENKINS_URL}/job/${JOB_NAME}/buildWithParameters?token=$TOKEN_NAME&para1=parameter1&para2=parameter2

2. 接口调试工具

http://user:passwd@${JENKINS_URL}/job/${JOB_NAME}/buildWithParameters?token=$TOKEN_NAME&1=parameter1&2=parameter2

3. curl

curl -s -u user:passwd -X GET http://${JENKINS_URL}/job/${JOB_NAME}/buildWithParameters?token=$TOKEN_NAME&1=parameter1&2=parameter2

4. 脚本

./remote-jenkins-job.sh -u http://${JENKINS_URL} -a user:passwd -j ${JOB_NAME} -p "1=parameter1" -p "2=parameter2" -t $TOKEN_NAME

脚本:https://bitbucket.org/sbrella-alex/remote-jenkins-job.git

2. 变量

1. ${BUILD_LOG, maxLines,escapeHtml}

$BUILD_LOG 默认打印最后250行

${BUILD_LOG, maxLines=20,escapeHtml=true} 打印最后20行,转义为HTML

这几个变量不错:

${BUILD_LOG_REGEX,regex="Reports are uploaded to"}

${BUILD_LOG_EXCERPT, start="Congratulations! Uploading successfully.", end="Complete uploading reports."}

最终用这个完美提取出url

${BUILD_LOG_MULTILINE_REGEX,showTruncatedLines="false",regex="http://172.20.135.174:40077/online_report(.*)\n",escapeHtml="false"}

https://issues.apache.org/jira/browse/LUCENE-4092

上一篇下一篇

猜你喜欢

热点阅读