I have a GitLab ci pipeline and I am not sure how to get it to generate an artifact with the binary file that happened in the build stage.
Here is my yml file...
stages:
- test
- build
- art
image: golang:1.9.2
variables:
BIN_NAME: example
ARTIFACTS_DIR: artifacts
GO_PROJECT: example
before_script:
- mkdir -p ${GOPATH}/src/${GO_PROJECT}
- mkdir -p ${CI_PROJECT_DIR}/${ARTIFACTS_DIR}
- go get -u github.com/golang/dep/cmd/dep
- cp -r ${CI_PROJECT_DIR}/* ${GOPATH}/src/${GO_PROJECT}/
- cd ${GOPATH}/src/${GO_PROJECT}
test:
stage: test
script:
# Run all tests
go test -run ''
build:
stage: build
script:
# Compile and name the binary as `hello`
- go build -o hello
# Execute the binary
- ./hello
art:
script:
artifacts:
paths:
- ./hello
The test and build phases run fine but the art stage does not when it is added to the yml file.
I have found lots of examples on line but finding it hard to convert them to my exact situation.
All I want to for the artifact to appear as a download on the pipeline like in this link.
after trying solution suggested i get the following...
$ go build -o hello
$ ./hello
Heldfgdfglo 2
Uploading artifacts...
WARNING: ./hello: no matching files
ERROR: No files to upload
Job succeeded
Tried adding..
GOPATH: /go
and...
- cd ${GOPATH}/src/${GO_PROJECT}
now getting following error...
Uploading artifacts...
WARNING: /go/src/example/hello: no matching files
ERROR: No files to upload
Job succeeded
output shared as requested...
mkdir -p ${GOPATH}/src/${GO_PROJECT}
$ mkdir -p ${CI_PROJECT_DIR}/${ARTIFACTS_DIR}
$ go get -u github.com/golang/dep/cmd/dep
$ cp -r ${CI_PROJECT_DIR}/* ${GOPATH}/src/${GO_PROJECT}/
$ cd ${GOPATH}/src/${GO_PROJECT}
$ go build -o hello
$ pwd
/go/src/example
$ ls -l hello
-rwxr-xr-x. 1 root root 1859961 Jun 19 08:27 hello
$ ./hello
Heldfgdfglo 2
Uploading artifacts...
WARNING: /go/src/example/hello: no matching files
ERROR: No files to upload
Job succeeded