Search code examples
gogitlabcontinuous-integrationgrpc

how to generate pb file from proto files in ci/cd gitlab pipeline?


I am working on CI/CD pipeline (GitLab) build where I need to generate pb files from proto files over CI/CD pipeline. So in order to install proto compiler all below ways 1.apt-get update && apt-get install -y protobuf-compiler 2. go get -u github.com/golang/protobuf/protoc-gen-go But in both ways I am getting error below error.

protoc-gen-go: program not found or is not executable Please specify a program using absolute path or make sure the program is available in your PATH system variable --go_out: protoc-gen-go: Plugin failed with status code 1.


Solution

  • I think you need to install protoc in your CI/CD pipeline.

    apt-get update
    apt-get install -y protobuf-compiler
    go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
    go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
    

    Hit the below command to get env path

    go env
    

    Look for GOENV="{/path}". Copy the path and paste it inside {} below :-

    export PATH="$PATH:${/path}"