..

jenkins k8s 编译 golang 遇到 vendor 的坑

将当前项目 link 到 /go/src/github.com/project,将 vendor 复制到 /go/src/

stage("go build") {
    steps {
        container("golang") {
            sh """
                cp vendor/* /go/src/ -rf
                mkdir -p /go/src/github.com/project
                ln -s `pwd` /go/sr/github.com/project
                cd /go/src/github.com/project && go build
            """
        }
    }
}

参考链接: