diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..85c74b4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,33 @@ +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将早退。 + } +} \ No newline at end of file