Home > Software engineering >  Build command not found. 'go'
Build command not found. 'go'

Time:05-20

....
jobs:
    setup:
    name: Setup
    runs-on: [self-hosted, Linux, X64]
    

    steps:
      - name: Set up Go 1.17
        uses: actions/setup-go@v2
        with:
          go-version: 1.17
          id: Go

      - name: work around permission issue
        run: git config --global --add safe.directory /__w/****-***/****-***

      - name: Checkout code into go module directory
        uses: actions/checkout@v2

      - name: Make Directory
        run: mkdir build

      - name: Build
        run: |
          CGO_ENABLED=0 go build -ldflags "-linkmode external" -o main
      - name: Upload Build
        uses: actions/upload-artifact@v2
        with:
          name: binary
          path: main

    scans :
    needs: setup
    name: all scans
    runs-on: [self-hosted, Linux, X64]
    steps:
      - name: Download build for build and test
        uses: actions/download-artifact@v2
        with:
          name: build

      - name: Coverity Scan
        env:
          AUTH_DATA: ${{ secrets.COVERITY_KEY_FILE }}
        run: |
          export PATH=$PATH:/opt/coverity/coverity-base/bin
          mkdir coverity
          cov-build --dir coverity go build main.go
          cov-analyze --dir coverity  --strip-path=`pwd`
          touch auth_key_file
          chmod 600 auth_key_file
          echo $( printf "%s" "$AUTH_DATA" ) > auth_key_file
          cov-commit-defects --dir coverity  --url `suspicious_url`  --auth-key-file auth_key_file --stream ****-overrides

      - name: Upload Coverity
        uses: actions/upload-artifact@v2
        with:
          name: coverity
          path: coverity

I have this workflow file for my Golang project. I want to run the Coverity scan. But when I am running this it's throwing an error :

Error

I have set up go in setup step. I don't know why it is telling that it did not found the go command. Please help me with this.

CodePudding user response:

Looks like you're only updating the $PATH in scans, but this ought to be in setup I think:

 export PATH=$PATH:/opt/coverity/coverity-base/bin

CodePudding user response:

Go may not be in the path of the process executing that command. You may need to modify the $PATH variable to include the path to your go binary.

  • Related