document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. var request = require(\'sync-request\');
  2. const hostName = \'http://your.gitlab.hostname\';
  3. const projectId = \'your.project.id\';
  4. const privateToken = \'your.private.token\';
  5.  
  6. function readPipelineVariable(varName) {
  7.   var res = request(
  8.     \'GET\',
  9.     `${hostName}/api/v3/projects/${projectId}/variables`,
  10.     {
  11.       headers: {
  12.         \'Content-Type\': \'application/json\',
  13.         \'Private-Token\': privateToken
  14.       }
  15.     }
  16.   );
  17.   var json = JSON.parse(res.getBody(\'utf8\'));
  18.   for (var x = 0; x < json.length; x++) {
  19.     if (json[x].key == varName) {
  20.       console.log(varName + \': \' + json[x].value);
  21.       return json[x].value;
  22.     }
  23.   }
  24. }
  25.  
  26. module.exports = {
  27.   readPipelineVariable: readPipelineVariable
  28. };
');