test-day-173

Today’s Task

  • Build Script User Friendly Changes
  • Refactor Build Scripts
  • Hadar Groovy Liquibase Job Support

Additional Task

Thought

试着在 Jenkins Job 执行完之前拿到了当前 job 的 console log

需要去 Approve 一些奇怪的权限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
stage('Result Analysis') {
steps {
script {
def logContent = Jenkins.getInstance().getItemByFullName(env.JOB_NAME).getBuildByNumber(Integer.parseInt(env.BUILD_NUMBER)).logFile.text
writeFile file: "${env.WORKSPACE}/buildConsolelog.txt", text: logContent
def consoleOutput = readFile "${env.WORKSPACE}/buildConsolelog.txt"

def keywords = ["ERROR", "WARNING", "author", "conflict"]

for(line in consoleOutput.split("\n")) {
for (keyword in keywords) {
if (line.contains(keyword)) {
echo line
} else if (line.contains("changes")) {
changes += line
echo line
}
}
}
}
}
}