I'm using the travis client to write a ruby script to interact with my TravisCI builds. I have a working .travis.yml file with a series of encrypted env vars. I'm trying to trigger the build from my script with a new env_var that overwrites one of the existing encrypted env vars in the travis.yml but I am unable to override the .yml configuration.
When making API call using CURL, I can successfully override the env var.
body='{
"request": {
"branch":"master",
"config": {
"merge_mode": "deep_merge",
"env": {
"SOME_ENV_VAR_DEFINED_IN_YML": '"$some_new_value_for_the_old_key"'
}
}
}
}'
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token MYSECRETTOKEN" \
-d "$body" \
https://api.travis-ci.com/repo/MYORG%2FMYREPO/requests
This is what I'm trying to do with the client in the script but not able to.
I've tried getting the repo and setting some env vars thusly:
my_repo = Travis::Pro::Repository.find("MYREPO")
my_repo.env_vars.upsert("SOME_ENV_VAR_DEFINED_IN_YML", "some_new_value", public: true)
Nada. It sets the env var on the repo that I can see in the travis ui but doesn't override the .yml config.
I've also tried setting the config object on the build that I want.
build_that_i_am_targeting.config["global_env"][index_of_env_var]="SOME_ENV_VAR_DEFINED_IN_YML=some_new_value"
Also nada - when setting off the build it resets the global env vars to the previous version.
Link to what I thought was relevant documentation: https://github.com/travis-ci/travis.rb#build-environment-variables
I was considering using the client session (just below the above in the docummentation) but I feel like there is something simpler that I'm missing. Any suggestions/ideas much appreciated! Thanks!