I am quite new to linux set up and I am finding it really tough to make my jenkins machine talk to a python program residing in a linux server.
Here are the details:
I have a python file which resides in a path '/filenet/EFBI/Scripts/Test_Scripts/add.py'
I have created one Jenkins Job to run the add.py file which has the JenkinsHome path set in the same linux machine -'/jenkins/jenkins_fmlvlm0000/jenkins2_176/Jenkins_Home'
I donot have access to the workspace file inside the Jenkins_Home (using a user to login to the linux box).
In the Jenkins Job configuration I have written the below code:
#! /usr/local/bin python3
python3 /filenet/EFBI/Scripts/Test_Scripts/add.py
When this gets executed receiving a error:
started by user Jenkins Admin User
Running as System
Building in workspace /jenkins/jenkins_fmlvlm0000/jenkins2_176/Jenkins_Home/Workspace/PythonTest
[PythonTest] $ /usr/local/bin python3 /jenkins/jenkins_fmlvlm0000/jenkins2_176/apache-tomcat-9.0.20/temp/jenkins123456789.sh
FATAL : command execution failed
java.io.IOException: error=13, Permission Denied
....
....
....
....
caused: java.io.IOException: cannot run program "/usr/local/bin" (in directory "/jenkins/jenkins_fmlvlm0000/jenkins2_176/Jenkins_Home/Workspace/PythonTest"): error=13, Permission Denied
Now I have below questions:
Where am I going wrong?
How to find out which user is being used to interact between jenkins and linux python program?
Is this a permission issue and what all permission be required?
The issue is resolved now.
We had to create a slave node and then in the linux machine create a worker folder for the agent to work.
And then in the set up create the same user ID and password through which we are logging into to linux machine and then provide required SSH permission to make it work.
Related
I am trying to setup remote development on PyCharm. For this, I want to make changes locally and execute the code on remote Amazon EC2 instance with a remote interpreter. I had done the following configuration of the project, but I am getting run error when I try to execute a ipython file created locally.
Cannot run program "stfp://<remote server hostname>/<remote server host>:<remote interpreter path>" (in directory <local folder directory>): error=2, No such file or directory.
It seems it should open <remote folder directory> instead of <local folder directory> when running the program. I read through multiple setup instructions but could not get this fixed. I am attaching configuration below.
Can you please help me with what could be wrong?
Updating PyCharm to 2022.3 can fix the issue. This seems to be related to an unstable older version.
I have an Azure VM into which I SSH in. The VM is a W10 host.
I can create files with touch, change directories and so on, but whenever I try to run a python script that is hosted on the VM I get the following error:
The system cannot execute the specified program.
At first glance I thought that there was a problem related to my pyhton alias and the PATH variable, so I decided to use RDP to log into the machine, open a CMD and try the same command, which worked just fine. The python program executed flawlessly.
I used where to find where is my python.exe located at, so whenever I run the script on my remote terminal I can do something like:
C:\Users\User01\AppData\Local\Microsoft\WindowsApps\python.exe test.py
This does result in the same error message as the one stated above.
Can I get some help?
Hi try to execute your command as below.
ssh user#machine python < script.py
I have a python script that uses Popen to create an appium server for a simulator on a mac
self.appium_process = subprocess.Popen(["/usr/local/bin/appium", "-a", self.ip, "--nodeconfig", self.node_file_path, "--relaxed-security", "-p", str(appium_port), "-dc", default_capabilities], stdout=log_file, stderr=subprocess.STDOUT)
I created a bash shell script that calls the python script. When I run the script from the local box it works and the appium logs show the connection.
I need to run this remote via ssh however. So I use the following to call the script:
ssh 10.18.66.99 automation_fw/config/testscript.sh
This, however, always ends up with the log showing:
env: node: No such file or directory
I checked and the node app has an extra slash before its called:
$ which node
/usr/local/bin//node
$
I tried changing the path on the machine but no change. How can I get this to run from ssh in the same way as it can run locally on that same box
A
When you are running a command vis SSH you are not starting what's called a login shell (more about that here).
From the details you've shared, I would say it's some thing in your environment (running outside a logged-in shell), more specifically a problem with your $PATH variable. You might want to check /etc/environment or similar paths (depending on your Linux flavour) for the wrong value.
I am running pycharm 2017.2.3. I want to run my python script on a remote ec2 instance using sudo user through pycharm. How do I acieve this?
Follow the steps below:
Go to File -> Settings -> Project Interpreter and add a new interpreter
Click on + to add a new python interpreter and then click on SSH interpreter
Provide your EC2 Public DNS in HOST and ubuntu as username
Click Next and add the private_key.pem file.
See this article for more details:
PyCharm setup for AWS automatic deployment
It looks like you can configure your python interpreter over SSH with the professional version of PyCharm.
Configuring Remote Interpreter + PyCharm
Finally found an answer after a researching through the internet. We can have a script on remote machine as a pycharm interpreter. Create a following script on a remote machine and make sure the script is executable.
#!/bin/bash
sudo /usr/bin/python "$#"
Now change the project interpreter to point to the above script on remote machine in pycharm. Now every script you run on local machine gets executed on remote as a sudo user.
I have a remote server and I want to use Pycharm to execute my scripts on this remote server using SFTP and SSH. Everything works properly, except that, when running the scripts on the server through the Pycharm "Run" command, the PATH is wrong. I am trying to understand which file I should edit to properly set the PATH environmental variable. I am using a mac and the server runs ubuntu. After having installed several libraries on the server, I edited the .bashrc file in my home directory on the server to properly set up the PATH. Then the following happens:
If I login to the server using ssh and the mac terminal, the PATH is loaded correctly.
If I open a ssh session inside pycharm and connect to the server, the PATH is loaded correctly.
If I run a simple script (that only contains calls to the standard library) on the remote server through the Pycharm "Run" command, it works
If I run the full script on the remote server through the pycharm "Run" command, then in crashes: os.environ['PATH'] shows that the path is not correct
If I run the script by directly calling the python interpreter on the server using one of the terminal ssh session, then the PATH is set up properly and it works
So apparently the PATH is set up properly if I connect to it using ssh and the terminal, but when Pycharm tries to run it directly the PATH is not updated and it crashes.
So I am guessing pycharm doesn't look into .bashrc before running the program. Which file should I modify then? Note that the only "configuration" files present in my home directory on the remote server are .bashrc and .profile.
Note I do not have sudo privileges on this server.