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 [1mhttp://localhost:33253/index.html[0m
[31m✘[0m [1mbypass[0m failure for [1mminScore[0m assertion
The page does not contain a heading, skip link, or landmark region
Documentation: https://web.dev/bypass/
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
[31m✘[0m [1mlabel[0m failure for [1mminScore[0m assertion
Form elements do not have associated labels
Documentation: https://web.dev/label/
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
[31m✘[0m [1moffline-start-url[0m failure for [1mminScore[0m assertion
`start_url` does not respond with a 200 when offline
Documentation: https://web.dev/offline-start-url
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
[31m✘[0m [1mservice-worker[0m failure for [1mminScore[0m assertion
Does not register a service worker that controls page and `start_url`
Documentation: https://web.dev/service-worker
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
[31m✘[0m [1mtap-targets[0m failure for [1mminScore[0m assertion
Tap targets are not sized appropriately
Documentation: https://web.dev/tap-targets
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
[31m✘[0m [1mworks-offline[0m failure for [1mminScore[0m assertion
Current page does not respond with a 200 when offline
Documentation: https://web.dev/works-offline
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
⚠️ [1mredirects-http[0m warning for [1mminScore[0m assertion
Does not redirect HTTP traffic to HTTPS
Documentation: https://web.dev/redirects-http
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
⚠️ [1mrender-blocking-resources[0m warning for [1mmaxLength[0m assertion
Eliminate render-blocking resources
Documentation: https://web.dev/render-blocking-resources
expected: <=[32m0[0m
found: [31m1[0m
[2mall values: 1[0m
⚠️ [1muses-http2[0m warning for [1mminScore[0m assertion
Does not use HTTP/2 for all of its resources
Documentation: https://web.dev/uses-http2
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0[0m
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
closing since found a resolution.
https://stackoverflow.com/questions/47098342/jenkinsfile-git-rev-parse-abbrev-ref-head-returns-head?answertab=votes#tab-top
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
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
(note:
$CURRENT_BRANCH_NAMEcan be anything. I'm using Codeship and they use$CI_BRANCH)and the problem is solved.