Jenkins中webdriver-manager更新geckodriver失败及执行异常求助
Let’s work through each of your problems one by one to get your e2e tests running smoothly in Jenkins:
1. Fixing the Geckodriver 403 Download Error
The tunneling socket could not be established, statusCode=403 error happens because your proxy isn’t properly handling requests to GitHub’s API (where geckodriver is hosted), while it works fine for Chrome’s driver storage. Here’s how to resolve it:
- Update proxy configuration: Ensure your Jenkins global proxy settings allow access to
api.github.comandgithub.com. If your proxy requires authentication, modify your webdriver-manager command to include credentials:node_modules/protractor/bin/webdriver-manager update --ignore_ssl --proxy=http://your-username:your-password@proxy-address:port --versions.gecko=v0.25.0 --versions.chrome=78.0.3904.105 - Verify manual download integrity: If you stick to manual downloads, make sure you grab the Linux 64-bit version of geckodriver v0.25.0 (not a variant for another OS) and confirm the
.tar.gzfile isn’t corrupted. The earlier unzip failure was almost certainly due to a partial/corrupted file from the 403 error.
2. Resolving the EACCES Permission Error
The spawn ... EACCES error means the Jenkins user doesn’t have execute permissions for the geckodriver binary. Even though logs mention permissions were set to 0755, manual file placement or Jenkins file ownership can override this:
- Manually set execute permissions: Add a shell step in your Jenkins build (before running
ng e2e) to fix permissions:chmod +x /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0 - Check file ownership: Ensure the geckodriver file is owned by the
jenkinsuser or a group with execute access. Run this on your Jenkins node to verify:
If needed, adjust ownership with:ls -l /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0chown jenkins:jenkins /var/lib/jenkins/jobs/x/workspace/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.25.0
3. Validating DirectConnect Configuration
Your directConnect: true is correct in theory, but Jenkins environments often need extra Firefox configuration:
- Specify Firefox binary path: Jenkins might not have Firefox in its default PATH. Add the binary location to your
protractor.conf.js:exports.config = { directConnect: true, capabilities: { browserName: 'firefox', 'moz:firefoxOptions': { binary: '/usr/bin/firefox', // Replace with your actual Firefox path args: ['--headless', '--no-sandbox'] // Critical for headless Jenkins environments } }, // ... other configs }; - Confirm version compatibility: Your Firefox 60.9.0 and geckodriver v0.25.0 are compatible (v0.25.0 supports Firefox 55-70), so that’s not the root issue here.
Final Recommended Workflow
- Fix your proxy settings (or use authenticated proxy) to let webdriver-manager download geckodriver correctly.
- Add a pre-test shell step to ensure geckodriver has execute permissions.
- Update your protractor config to include the Firefox binary path and headless mode arguments.
内容的提问来源于stack exchange,提问作者Buvi

