CentOS Jenkins环境构建Maven项目遇chromedriver不可执行错误求助
Hey there, let's work through this chromedriver permission issue—this is a super common problem when running Selenium tests on Jenkins in CentOS, and I've fixed it a bunch of times. Here's exactly what you need to do:
1. Add Executable Permissions to Chromedriver
The error directly tells us the chromedriver file doesn't have execute permissions. Run this command to grant them:
chmod +x /var/lib/jenkins/jobs/autocred-ui-automated-tests/workspace/autocredenciamento/chromedriver
2. Ensure Jenkins User Owns the File
Jenkins runs under the jenkins system user, so if the chromedriver was uploaded or created by another user (like root), Jenkins might not have access to it. Fix the file ownership with:
chown jenkins:jenkins /var/lib/jenkins/jobs/autocred-ui-automated-tests/workspace/autocredenciamento/chromedriver
3. Handle SELinux Restrictions (CentOS-Specific)
CentOS enables SELinux by default, which can block Jenkins from executing files even if filesystem permissions are correct.
First, test if SELinux is the culprit by temporarily disabling it (this is just for testing—don't leave it off permanently):
setenforce 0
If your test builds successfully after this, you need to update the SELinux context for chromedriver to mark it as a valid executable:
chcon -t bin_t /var/lib/jenkins/jobs/autocred-ui-automated-tests/workspace/autocredenciamento/chromedriver
This tells SELinux that the file is a trusted binary executable, so it won't block Jenkins from running it.
Quick Check After Fixes
Once you've run these commands, kick off a new Jenkins build. The beforeMethod failure should be gone, and your Selenium tests should be able to launch Chrome properly.
Just a quick side note: Make sure your chromedriver version matches the installed Chrome browser version on your Jenkins server—permission issues are the fix here, but version mismatches can cause other errors later on.
内容的提问来源于stack exchange,提问作者anderson mann

