Няма описание

triggerExampleProjBuild.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env node
  2. "use strict";
  3. var shell = require('shelljs');
  4. var path = require('path');
  5. var got = require('got');
  6. var targetRepo = 'dpa99c/cordova-custom-config-example';
  7. console.log("Fetching Git commit hash...");
  8. var gitCommitRet = shell.exec('git rev-parse HEAD', {
  9. cwd: path.join(__dirname, '..')
  10. });
  11. if (0 !== gitCommitRet.code) {
  12. console.error('Error getting git commit hash');
  13. process.exit(-1);
  14. }
  15. var gitCommitHash = gitCommitRet.stdout.trim();
  16. console.log("Git commit: "+gitCommitHash);
  17. console.log('Calling Travis...');
  18. got.post("https://api.travis-ci.org/repo/"+encodeURIComponent(targetRepo)+"/requests", {
  19. headers: {
  20. "Content-Type": "application/json",
  21. "Accept": "application/json",
  22. "Travis-API-Version": "3",
  23. "Authorization": "token "+process.env.TRAVIS_API_TOKEN
  24. },
  25. body: JSON.stringify({
  26. request: {
  27. message: "Trigger build at "+targetRepo+" commit: "+gitCommitHash,
  28. branch: 'master'
  29. }
  30. })
  31. })
  32. .then(function(){
  33. console.log("Triggered build of "+targetRepo);
  34. })
  35. .catch(function(err){
  36. console.error(err);
  37. process.exit(-1);
  38. });