The Fool
The Fool

Reputation: 20547

How to add go binary as bitbucket pipeline artifact?

Hello I am trying to add the output binary of my pipeline to the build-in artifactory.

image: golang:1.13

pipelines:
  default:
    - step:
        script:
          - PACKAGE_PATH="${GOPATH}/src/bitbucket.org/${BITBUCKET_REPO_FULL_NAME}"
          - mkdir -pv "${PACKAGE_PATH}"
          - tar -cO --exclude-vcs --exclude=bitbucket-pipelines.yml . | tar -xv -C "${PACKAGE_PATH}"
          - cd "${PACKAGE_PATH}"
          - go get -v
          - env GOOS=windows GOARCH=amd64 go build
          - go build -v
          - ls
        artifacts:
          - fx_update.exe


However, the binary does not end up in the artifactory:

enter image description here

So I threw this ls command in there to see if the .exe is present and Indeed it is:

enter image description here

Does anyone know why it's not doing what I want?

Upvotes: 1

Views: 1340

Answers (1)

Alexander Zhukov
Alexander Zhukov

Reputation: 4557

That's because you cd to the package directory before creating artifacts. Artifacts definitions are relative to the build directory, not to the current working directory (see this page for more details https://confluence.atlassian.com/bitbucket/using-artifacts-in-steps-935389074.html). You can fix this by copying the fx_update.exe to the base build directory:

- step:
    script:
      - PACKAGE_PATH="${GOPATH}/src/bitbucket.org/${BITBUCKET_REPO_FULL_NAME}"
      - mkdir -pv "${PACKAGE_PATH}"
      - tar -cO --exclude-vcs --exclude=bitbucket-pipelines.yml . | tar -xv -C "${PACKAGE_PATH}"
      - cd "${PACKAGE_PATH}"
      - go get -v
      - env GOOS=windows GOARCH=amd64 go build
      - go build -v
      - cp fx_update.exe ${BITBUCKET_CLONE_DIR}
    artifacts:
      - fx_update.exe

Upvotes: 3

Related Questions