I'm using Travis-CI
to build my Go
project and so far I used the gimme
script with combination of travis go environment to cross-compile the project.
I switch to Go 1.5 that supports the GOOS
and GOARCH
environment variables to cross compiler without the need of other compilers or scripts.
My problems is that I'm using Bintray deploy and my environment variables are not exposed in the deploy phase.
language: go
go:
- 1.5
env:
matrix:
- GOOS=windows GOARCH=amd64
- GOOS=linux GOARCH=amd64
- GOOS=linux GOARCH=386
- GOOS=darwin GOARCH=amd64
before_script:
- go get -d -v ./...
script:
- go build -v ./...
before_deploy:
- chmod +x ./prepare_bintray_deployment.sh
- "./prepare_bintray_deployment.sh"
deploy:
file: bintray_descriptors/${GOOS}_${GOARCH}.json
provider: bintray
Note that before this change I was using the GIMME_OS
and GIMME_ARCH
environment variables and it worked fine and this makes me believe that Travis does support this.
What could be the problem?
Configuration. Travis CI is configured by adding a file named . travis. yml , which is a YAML format text file, to the root directory of the repository.
Prerequisites # To start using Travis CI, make sure you have: A GitHub or Bitbucket or GitLab or Assembla account. Owner permissions for a project hosted on GitHub or Bitbucket or GitLab or Assembla.
Something like this worked for me:
script:
- # do some build stuff here
- echo ${MY_VAR} > my_var.txt
before_deploy:
- export MY_VAR=$(cat my_var.txt)
deploy:
file: foo/bar_${MY_VAR}.json
skip_cleanup: true
Essentially, you can't seem to access dynamic vars exported from the script section in the deploy section, but you can write them down (output to a file) and then access them later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With