environment variables - Skipping parts of a Travis job if building from a fork -


i've been writing shell tasks can't run unless there secure environment variables present in travis ci pr build. there auth token must present push information build, builds originating forks, i'd skip these parts. they're not critical.

how can tell if build originating fork?

from the documentation around "environment variables":

travis_secure_env_vars: whether or not secure environment vars being used. value either "true" or "false".

this little ambiguous. mean secure environment variables being used anywhere (as in, present in .travis.yml)? being exported environment variables in current build? i'm not sure way guarantee i'm testing pull request has originated fork, didn't see other way it.

my first attempted had code looked like

[ ${travis_secure_env_vars} = "false" ] && exit 0; # more shell code here... 

but appears continue ahead , push without auth token, failing task (and build). further complicating matters should command fail, output may contain auth token...so stderr , stdout redirected /dev/null. considering builds don't start several minutes, i'm stuck waiting in long debug cycle.

my next attempt bypassed built-in environment variable, in favor of instead trying grab secure environment variable directly.

[ ${ghtoken} -n ] && exit 0; 

this fails in same way above. i'm beginning wonder if [ $cond ] && exit 0; works way i'm expecting in context. seems work fine when run equivalent shell scripts locally (mac osx , bash).

does travis offer built-in way determine if pull request being built originated original repository versus fork?

here current work around.

screenshotsclone: {     command: ['[ ${ghtoken} ] &&',               'git submodule add -f', screenshotpulltemplate, 'screenshots > /dev/null 2>&1;'].join(' '),     options: {         stdout: false,         failonerror: false     } } 

i'd rather not silently pass on errors should there legitimate problem shell task. @ point might remove environment variable check precedes it.

stop using grunt-shell things in .travis.yml. put shell tasks own files can stop using /bin/sh , start using /bin/bash, you've been testing against locally.

something fix problems.

don't forget mark shebang #! /bin/bash, crucial kinds of checks should happening on travis.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -