github - Set up upstream project in Travis CI -


i'm working on project, have 2 git repos:

repo1 - devrepo, rep02- testrepo

my scenario is: whenever commit or pr happens on repo1:

step1: repo2 should triggered

step2: once step1 success, repo1 should triggered.

basically repo1 should build if repo2 run , turns success.

could please me how can set up, appreciated:

  • which .travis.yml file should configure meet scenario.
  • exact configuration steps can write in .travis.yml file

answer: got working:

  1. trigger dependent build: repo2 using travis api: create trigger_build.sh file , add code:
` body='{ "request": {   "branch":"master" }}'  curl -s -x post \   -h "content-type: application/json" \   -h "accept: application/json" \   -h "travis-api-version: 3" \   -h "authorization: token ..git_hub_login_token.." \   -d "$body" \   https://api.travis-ci.org/repo/xxxx%2fyyyy/requests  #the 15s sleep allow travis trigger dependent build: sleep 15` 
  1. create new or separate get_build_status.sh file. poll status of dependent build. based on status of repo2 build, either continue building repo1 or stop building repo1:
 # polling repo2 build status # setting maximum time repo2 build run, once status passed/failed, return repo1 build run  `i=1 max=300 while [ $i -lt $max ]  echo "--------------------------------------------" echo "polling tests run build status..."`  curl -i -h "accept: application/vnd.travis-ci.2+json" "https://api.travis-ci.org/repos/xxxx/yyyy/builds" > test.json latest_state=$(grep -o '"state":.[a-z\"]*' test.json | head -1) #latest_id=$(grep -o '"id":.[0-9]*' test.json | head -1 | grep ':.[0-9]*')  get_state_value=${latest_state#*:} state="${get_state_value//\"}"  if [ $state == "passed" ]   echo "tests run... $state :-) "   break #as repo2 run pass, break , return repo1 build run elif [ $state == "failed" ]  echo "tests run... $state :-("  echo "stop building elements"  exit 1 #as repo2 run fail, stop building repo1 fi  true $(( i++ )) sleep 1 #this 1s required poll build status every second done  
  1. your .travis.yml configuration:
 script: - chmod 777 ./trigger_build.sh - chmod 777 ./get_build_status.sh - ./trigger_build.sh - ./get_build_status.sh  

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -