From 5b94d7ec1780ebd25d2e7e15d336d5ad08bac6a1 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:56:44 +0800 Subject: [PATCH] stage test --- Jenkinsfile | 29 ++++++++++++++++------------- global/global_test.go | 10 ++++++++++ resJSON.go | 10 ---------- 3 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 global/global_test.go delete mode 100644 resJSON.go diff --git a/Jenkinsfile b/Jenkinsfile index 03f8061..0db09c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,20 +2,26 @@ pipeline { agent any stages { - stage('Build') { + stage('Test') { + steps { + sh 'echo "Start Test"' + sh 'PATH=$PATH:/var/jenkins_home/go/bin && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go mod tidy' + sh 'PATH=$PATH:/var/jenkins_home/go/bin && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go test global/global_test.go' + } + } + stage('Compile') { steps { - sh 'echo "Hello World"' -// sh 'CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o exporter main.go' + sh 'echo "Start Build"' + sh 'PATH=$PATH:/var/jenkins_home/go/bin && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ipregion.bin main.go' } } - stage('Test') { + stage('Build') { steps { - /* `make check` returns non-zero on test failures, - * using `true` to allow the Pipeline to continue nonetheless - */ - sh 'ls' + sh 'echo "Start Build"' + sh 'PATH=$PATH:/var/jenkins_home/go/bin && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ipregion main.go' + sh 'docker build -t sre/ipregion:arm64 .' } - } + } stage('Deploy') { when { expression { @@ -24,10 +30,7 @@ pipeline { } } steps { - sh 'PATH=$PATH:/var/jenkins_home/go/bin' - sh 'echo $PATH' - sh 'PATH=$PATH:/var/jenkins_home/go/bin && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go mod tidy' - sh 'PATH=$PATH:/var/jenkins_home/go/bin && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ipregion main.go' + sh 'kubectl rollout restart deployment -n sre ipregion' } } //部署可能意味着各种步骤,具体取决于项目或组织的要求,并且可能是从构建的工件发送到Artifactory服务器,将代码推送到生产系统的任何步骤。 diff --git a/global/global_test.go b/global/global_test.go new file mode 100644 index 0000000..9b3f35b --- /dev/null +++ b/global/global_test.go @@ -0,0 +1,10 @@ +package global + +import ( + "fmt" + "testing" +) + +func TestGlobal(tt *testing.T) { + fmt.Println("test pass") +} diff --git a/resJSON.go b/resJSON.go deleted file mode 100644 index 28faaa1..0000000 --- a/resJSON.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -//type IpInfo struct { -// CityId int64 -// Country string -// Region string -// Province string -// City string -// ISP string -//}