dred17
dred17

Reputation: 159

Run appium server via Jenkins on Windows

I need to run appium server on Windows Jenkins slave.

I use the following command via "Execute windows command":

appium & --device_name Nexus_S 
mvn test

But when I run appium the command line just "hangs up" and showing server console continiously. What can I do to ignore that continious task and perform next command?

Upvotes: 0

Views: 5388

Answers (3)

Pratik Patel
Pratik Patel

Reputation: 2443

You can use appium & command.

& at the end of the command will run it in background and didn't freeze the terminal.

Please refer this answer

Upvotes: 0

Ayaz Alifov
Ayaz Alifov

Reputation: 8588

You can start the Appium using the following command:

call start cmd.exe /k PATH_TO_NODE_JS PATH_TO_APPIUM_JS --address IP_ADDRESS --port PORT_NUMBER

In my case:

  • PATH_TO_NODE_JS is C:/node/node.exe
  • PATH_TO_APPIUM_JS is C:/Users/saqada/AppData/Local/Programs/appium-desktop/resources/app/node_modules/appium/build/lib/main.js
  • IP_ADDRESS is 127.0.0.1
  • PORT_NUMBER is 4725

Complete command looks like:

call start cmd.exe /k C:/node/node.exe C:/Users/saqada/AppData/Local/Programs/appium-desktop/resources/app/node_modules/appium/build/lib/main.js --address 127.0.0.1 --port 4725

When you start an Appium server from Jenkins, then you don't need to stop it manually, because Jenkins handles it for you. Thus, after finishing a Jenkins job, the Appium server and all its related processes, which were created by Jenkins, will be terminated.

However, if you start an Appium from the command line and want to stop it, the you can use:

taskkill /f /fi "IMAGENAME eq node.exe" /t

Please, keep in mind, in some cases main.js doesn't work, and you need to use Appium.js, which you can find in the same location as main.js

Upvotes: 0

Tomas
Tomas

Reputation: 1887

You need to run appium as new process.

To run appium use:

call start "appium" appium & --device_name Nexus_S

It will start new process with name starting with "appium" (you can choose which name you want). This name you can later use for killing that process.

To kill appium use:

taskkill /f /fi "WINDOWTITLE eq appium*" /t

It will kill process with name (we used before) starting with "appium". Parameter /t means that all child processes are killed too. (Appium server is not only one process)

Upvotes: 4

Related Questions