title: Automating the license checking in gitlab CI/CD pipeline
body: <p>I am trying to implement the license checking of the installed packages in my react project on a GitLab CI/CD pipeline. Before the build stage, the pipeline should check all the available licenses and then whitelist or blacklist certain specified licenses.</p>
  <p>I am using the <a href="https://www.npmjs.com/package/license-checker" rel="nofollow noreferrer">license-checker package</a> to implement a list of available licenses in a JSON file.
  After executing the required command: <code>license-checker --json &gt; ./license.json</code>, the output is:</p>
  <p><strong>license.json</strong></p>
  <pre><code>{
    &quot;@babel/plugin-transform-parameters@7.10.1&quot;: {
      &quot;licenses&quot;: &quot;MIT&quot;,
      &quot;repository&quot;: &quot;https://github.com/babel/babel&quot;,
      &quot;path&quot;: &quot;..../node_modules/@babel/plugin-transform-parameters&quot;,
      &quot;licenseFile&quot;: &quot;...../node_modules/@babel/plugin-transform-parameters/LICENSE&quot;
    },
    &quot;@babel/plugin-transform-property-literals@7.10.1&quot;: {
      &quot;licenses&quot;: &quot;MIT&quot;,
      &quot;repository&quot;: &quot;https://github.com/babel/babel&quot;,
      &quot;path&quot;: &quot;..../node_modules/@babel/plugin-transform-property-literals&quot;,
      &quot;licenseFile&quot;: &quot;...../node_modules/@babel/plugin-transform-property-literals/LICENSE&quot;
    },
    &quot;@babel/plugin-transform-react-constant-elements@7.10.1&quot;: {
      &quot;licenses&quot;: &quot;MIT&quot;,
      &quot;repository&quot;: &quot;https://github.com/babel/babel&quot;,
      &quot;path&quot;: &quot;..../node_modules/@babel/plugin-transform-react-constant-elements&quot;,
      &quot;licenseFile&quot;: &quot;...../node_modules/@babel/plugin-transform-react-constant-elements/LICENSE&quot;
    }
    // .........and list goes on
  }
  </code></pre>
  <p><strong>.gitlab-ci.yml</strong></p>
  <pre><code>include:
    - local: license-checker-config.yml
  
  stages: 
    - dependency
  
  dependency:
    image: node:12
    stage: dependency
    script: 
      - npm ci
      - echo &quot;main file....&quot;
  </code></pre>
  <p><strong>license-checker-config.yml</strong></p>
  <pre><code>before_script: 
    - ./license.json
    - echo &quot;Checking licenses...&quot;
  </code></pre>
  <p>License scanning should be initiated before the build process, so I included as a part of <code>before_script</code>.
  In <code>license-checker-config.yml</code>, I need to include my JSON file and then check by iterating over it, if it contains license like MIT, then only the build stage should continue otherwise the build should fail.</p>
  <p>With my current code setup, I executed the pipeline and got the error:</p>
  <pre><code>Executing &quot;step_script&quot; stage of the job script
  00:01
  $ ./license.json
  /bin/bash: line 99: ./license.json: Permission denied
  ERROR: Job failed: exit code 1
  </code></pre>
  <p>Even though the file license.json exists in the same root folder, it shows permission denied. Further, I am unable to figure out how to implement JSON file looping inside the yml file and then achieve the required.</p>
  <p>Any help to get me through this is highly appreciated.</p>