You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!groovy
//library 'sre-shared-library'
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'echo "Hello World"'
// sh 'CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o exporter main.go'
}
}
stage('Test') {
steps {
/* `make check` returns non-zero on test failures,
* using `true` to allow the Pipeline to continue nonetheless
*/
sh 'ls'
}
}
stage('Deploy') {
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
//访问该currentBuild.result变量允许Pipeline确定是否有任何测试失败。在这种情况下值将是 UNSTABLE。
}
}
steps {
sh 'echo ok'
}
}
//部署可能意味着各种步骤具体取决于项目或组织的要求并且可能是从构建的工件发送到Artifactory服务器将代码推送到生产系统的任何步骤。
//在Pipeline示例的这个阶段“构建”和“测试”阶段都已成功执行。实际上“部署”阶段只能在上一阶段成功完成否则Pipeline将早退。
}
}