|
|
|
|
@ -4,11 +4,7 @@ pipeline {
|
|
|
|
|
stages {
|
|
|
|
|
stage('Build') {
|
|
|
|
|
steps {
|
|
|
|
|
sh 'make'
|
|
|
|
|
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
|
|
|
|
|
//该sh步骤调用该make命令,只有在命令返回零退出代码时才会继续。任何非零退出代码将失败Pipeline。
|
|
|
|
|
//archiveArtifacts捕获与include pattern(**/target/*.jar)匹配的文件,并将它们保存到Jenkins主文件以供以后检索。
|
|
|
|
|
//存档工件不能替代使用诸如Artifactory或Nexus之类的外部工件存储库,只能用于基本报告和文件归档。
|
|
|
|
|
sh 'CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o exporter main.go'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stage('Test') {
|
|
|
|
|
@ -16,11 +12,7 @@ pipeline {
|
|
|
|
|
/* `make check` returns non-zero on test failures,
|
|
|
|
|
* using `true` to allow the Pipeline to continue nonetheless
|
|
|
|
|
*/
|
|
|
|
|
sh 'make check || true'
|
|
|
|
|
junit '**/target/*.xml'
|
|
|
|
|
//运行自动化测试是任何成功的连续传送过程的重要组成部分。因此,Jenkins有许多插件提供的测试记录,报告和可视化设备 。在基本层面上,当有测试失败时,让Jenkins在Web UI中记录报告和可视化的故障是有用的。
|
|
|
|
|
//下面的示例使用junit由JUnit插件提供的步骤。
|
|
|
|
|
//在下面的示例中,如果测试失败,则Pipeline被标记为“不稳定”,如Web UI中的黄色球。根据记录的测试报告,Jenkins还可以提供历史趋势分析和可视化。
|
|
|
|
|
sh 'ls'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stage('Deploy') {
|
|
|
|
|
@ -31,7 +23,7 @@ pipeline {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
sh 'make publish'
|
|
|
|
|
sh 'echo ok'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//部署可能意味着各种步骤,具体取决于项目或组织的要求,并且可能是从构建的工件发送到Artifactory服务器,将代码推送到生产系统的任何步骤。
|
|
|
|
|
|