master
dustoair 3 years ago
parent e1406e1e8d
commit 5b94d7ec17

29
Jenkinsfile vendored

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

@ -0,0 +1,10 @@
package global
import (
"fmt"
"testing"
)
func TestGlobal(tt *testing.T) {
fmt.Println("test pass")
}

@ -1,10 +0,0 @@
package main
//type IpInfo struct {
// CityId int64
// Country string
// Region string
// Province string
// City string
// ISP string
//}
Loading…
Cancel
Save