0

This is regarding executing a files python files in remote PC from jenkins using SSH

I have installed Jenkins on a Windows 10 PC.

The Remote PC is also a Windows 10 PC, which has anaconda3 installed and also OpenSSH servr

In Manage Jenkins -> Configure system -> SSH Remote hosts , i have set the host IP (Remote PC IP) , port (22) and credentials.

From the Jenkins PC, i have created a free style project, and entered the below command by choosing the a prebuild option "Execute shell script on remote host using SSH"

The commands i used are as below.

date

cd d:\MyAppFolder

py .\bin\myApp.py

When i build the jenkins job, it prints the date and also the CD command seems to succeed. Next i see that the python scripts does execute, but fails to import modules. So i think,the python script is not executing in the required conda environment.

I have installed all required moduels in the base conda environment, in the remote PC.

How do i activate the conda base environment in the remote PC and execute the python script from jenkins job?

thanks and regards

pachu
  • 1
  • 1
  • This seems to contain a lot of unrelated background. Your freestyle job will run code on the slave, so you don't need SSH to run anything there. If you do need to troubleshoot the Python path when logging in over SSH, concentrate on that and remove all the Jenkins stuff. See also the guidance for providing a [mre]. – tripleee Aug 11 '21 at 10:05
  • Actually, thats right... on slave we dont need SSH. I will clarify the situation. . the Build is done on the slave machine. Post the build, i need to deploy on to another third PC, which isn't a slave. So i am using SSH to remotely execute some python files. – pachu Aug 11 '21 at 10:33
  • This is a common FAQ as such, but there are many ways you can fail to attach to an existing Conda environment. Again, probably reduce the question to something like "I use SSH and run _this_ command in _this_ conda environment, which was set up like _this._ The module I want to use is installed in _here,_ should the commands I ran above (which please include, obviously) not have activated that env?" – tripleee Aug 11 '21 at 10:38
  • I have updated the query, i hope it is quite to the point... if you feel i need to add some more info, please do let me know. – pachu Aug 11 '21 at 11:44
  • Because you need to activate the environment at the start of the SSH session. – tripleee Aug 11 '21 at 11:49
  • I tried those suggestion in the above duplicate link, but still it fails. – pachu Aug 11 '21 at 12:03
  • 2
    Does this answer your question? [How to activate an Anaconda environment](https://stackoverflow.com/questions/20081338/how-to-activate-an-anaconda-environment) – Shanteshwar Inde Aug 11 '21 at 14:04

0 Answers0