update jenkinsfile

master
sre 3 years ago
parent e3eea60c75
commit 2871164052

14
Jenkinsfile vendored

@ -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服务器将代码推送到生产系统的任何步骤。

@ -0,0 +1,40 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make'
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
//该sh步骤调用该make命令只有在命令返回零退出代码时才会继续。任何非零退出代码将失败Pipeline。
//archiveArtifacts捕获与include pattern**/target/*.jar匹配的文件并将它们保存到Jenkins主文件以供以后检索。
//存档工件不能替代使用诸如Artifactory或Nexus之类的外部工件存储库只能用于基本报告和文件归档。
}
}
stage('Test') {
steps {
/* `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还可以提供历史趋势分析和可视化。
}
}
stage('Deploy') {
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
//访问该currentBuild.result变量允许Pipeline确定是否有任何测试失败。在这种情况下值将是 UNSTABLE。
}
}
steps {
sh 'make publish'
}
}
//部署可能意味着各种步骤具体取决于项目或组织的要求并且可能是从构建的工件发送到Artifactory服务器将代码推送到生产系统的任何步骤。
//在Pipeline示例的这个阶段“构建”和“测试”阶段都已成功执行。实际上“部署”阶段只能在上一阶段成功完成否则Pipeline将早退。
}
}
Loading…
Cancel
Save