Search code examples
jenkinsjenkins-cli

Jenkins build showing "Operation not permitted"


I have installed JENKINS and created a bob, But the job is getting failed with the below error.I have tried many thing like giving permissions and all but cannot able to make it run.

Can anyone please let me know what could be the reason and how to make it run.?

13:45:49 Started by timer
13:45:49 Running as SYSTEM
13:45:49 Building in workspace /Users/it/.jenkins/workspace/CE
13:45:49 [google_crawler] $ /bin/sh -xe /var/folders/t2/sk1vw_mn7mz7ncjw75lzh7r40000gn/T/jenkins1637440588980893865.sh
13:45:49 + export PYTHONPATH=/Users/it/Documents/
13:45:49 + PYTHONPATH=/Users/it/Documents/
13:45:49 + cd /Users/it/Documents/CE
13:45:49 + python3 continious_execution.py
13:45:50 /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'continious_execution.py': [Errno 1] Operation not permitted
13:45:50 Build step 'Execute shell' marked build as failure
13:45:50 Finished: FAILURE

Below is the Build Code:

export PYTHONPATH=${PYTHONPATH:-"/Users/it/Documents/"}
cd /Users/it/Documents/CE
python3 continious_execution.py

Note: if i'm running it in TERMINAL it is running fine(Using MAC system). The user of Jenkins is "jenkins_admin" which i put in JENKINS while installation & the Windows user logged in is "IT".Im not sure about these permissions and settings can anyone please guide me through it?


Solution

  • It may fail because your 'jenkins_admin' user has no permission to read from home directory of 'it' user You can do one of the following

    1. Move python script to other directory (I think it's the best way)
    2. Change user to 'it', when executing shell script (see su)
    3. Give permissions to read and execute this file to 'jenkins_admin' user (see chmod)
      chmod -R o+r /Users/it
    
      chmod 777 /Users/it/Documents/CE/continious_execution.py