Lighthouse-ci: Unable to determine current branch with git rev-parse --abbrev-ref HEAD

Created on 8 Jan 2020  ·  3Comments  ·  Source: GoogleChrome/lighthouse-ci

Hi all,

Im trying to setup LHCI and upload results to LHCI-server.
Using jenkins and github.

Im getting following error and upload to ci-server get fails. Is this an issue in jenkins or @lhci ?

Error: Unable to determine current branch with git rev-parse --abbrev-ref HEAD

+ lhci autorun --upload.target=lhci
✅  .lighthouseci/ directory writable
✅  Configuration file found
✅  Chrome installation found
✅  GitHub token set
⚠️   Ancestor hash not determinable
    ERROR: Unable to determine current branch with `git rev-parse --abbrev-ref HEAD`
✅  LHCI server reachable
✅  LHCI server token valid
⚠️   LHCI server non-unique build for this hash
    ERROR: Unable to determine current branch with `git rev-parse --abbrev-ref HEAD`
Healthcheck passed!

Automatically determined ./build as `staticDistDir`.
Set it explicitly in lighthouserc.json if incorrect.

Started a web server on port 33253...
Running Lighthouse 1 time(s) on http://localhost:33253/index.html
Run #1...done.
Done running Lighthouse!

Checking assertions against 1 URL(s), 1 total run(s)

9 result(s) for http://localhost:33253/index.html

  ✘  bypass failure for minScore assertion
     The page does not contain a heading, skip link, or landmark region
     Documentation: https://web.dev/bypass/

        expected: >=1
           found: 0
      all values: 0


  ✘  label failure for minScore assertion
     Form elements do not have associated labels
     Documentation: https://web.dev/label/

        expected: >=1
           found: 0
      all values: 0


  ✘  offline-start-url failure for minScore assertion
     `start_url` does not respond with a 200 when offline
     Documentation: https://web.dev/offline-start-url

        expected: >=1
           found: 0
      all values: 0


  ✘  service-worker failure for minScore assertion
     Does not register a service worker that controls page and `start_url`
     Documentation: https://web.dev/service-worker

        expected: >=1
           found: 0
      all values: 0


  ✘  tap-targets failure for minScore assertion
     Tap targets are not sized appropriately
     Documentation: https://web.dev/tap-targets

        expected: >=1
           found: 0
      all values: 0


  ✘  works-offline failure for minScore assertion
     Current page does not respond with a 200 when offline
     Documentation: https://web.dev/works-offline

        expected: >=1
           found: 0
      all values: 0


  ⚠️  redirects-http warning for minScore assertion
     Does not redirect HTTP traffic to HTTPS
     Documentation: https://web.dev/redirects-http

        expected: >=1
           found: 0
      all values: 0


  ⚠️  render-blocking-resources warning for maxLength assertion
     Eliminate render-blocking resources
     Documentation: https://web.dev/render-blocking-resources

        expected: <=0
           found: 1
      all values: 1


  ⚠️  uses-http2 warning for minScore assertion
     Does not use HTTP/2 for all of its resources
     Documentation: https://web.dev/uses-http2

        expected: >=1
           found: 0
      all values: 0

Assertion failed. Exiting with status code 1.

Error: Unable to determine current branch with `git rev-parse --abbrev-ref HEAD`
    at getCurrentBranchRaw_ (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest_node/lib/node_modules/@lhci/cli/node_modules/@lhci/utils/src/build-context.js:127:11)
    at getCurrentBranch (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest_node/lib/node_modules/@lhci/cli/node_modules/@lhci/utils/src/build-context.js:137:18)
    at runLHCITarget (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest_node/lib/node_modules/@lhci/cli/src/upload/upload.js:227:18)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async run (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest_node/lib/node_modules/@lhci/cli/src/cli.js:90:7)
WARNING: upload command failed.
assert command failed. Exiting with status code 1.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Most helpful comment

https://github.com/GoogleChrome/lighthouse-ci/blob/8d0b6761f0db1dd032448acbecb08c553ff17495/packages/utils/src/build-context.js#L104-L121

In case somebody looking for a solution for the error message, I looked into the source code where LHCI looks up current git branch name (above) and I used

export LHCI_BUILD_CONTEXT__CURRENT_BRANCH = $CURRENT_BRANCH_NAME

(note: $CURRENT_BRANCH_NAME can be anything. I'm using Codeship and they use $CI_BRANCH)

and the problem is solved.

All 3 comments

https://github.com/GoogleChrome/lighthouse-ci/blob/8d0b6761f0db1dd032448acbecb08c553ff17495/packages/utils/src/build-context.js#L104-L121

In case somebody looking for a solution for the error message, I looked into the source code where LHCI looks up current git branch name (above) and I used

export LHCI_BUILD_CONTEXT__CURRENT_BRANCH = $CURRENT_BRANCH_NAME

(note: $CURRENT_BRANCH_NAME can be anything. I'm using Codeship and they use $CI_BRANCH)

and the problem is solved.

GitLab fix:

  before_script:
    - export LHCI_BUILD_CONTEXT__CURRENT_BRANCH=$CI_COMMIT_REF_NAME
Was this page helpful?
0 / 5 - 0 ratings