launch-slave script - jenkins

according to the jenkins wiki
/var/jenkins/bin/launch-slave is a shell script that Jenkins uses to execute jobs remotely. This shell script sets up PATH and a few other things before launching slave.jar. Below is a very simple example script
I'm running jenkins as JNLP and don't have a /bin, so I'm not sure where should i put this file

Run Jenkins 'headlessly', not via a browser:
java -jar slave.jar -jnlpUrl http://[jenkins_server]/computer/[slave-name]/slave-agent.jnlp
Write a script containing that command and add whatever else you want before it, including setting the new PATH.
You can also specify environment variables (or 'key-value pairs') in the slave node configuration. Navigate to http://[jenkins_server]/computer/[slave-name]/configure and check off 'Environment Variables' check-box.

The script on Jenkins wiki you refer to is meant as an example for those who want to use slaves of type "Launch slave by executing a command on master". If you are using JNLP type slaves, then you don't need this script.
What you need to do is log onto the slave machine, open the web browser to your Jenkins, navigate to the page of your slave and hit the orange button. Or use one of the command lines on the page to run the slave.

Related

Jenkins Ranorex plugin not executing test

I am new to Jenkins. I have master and slave configuration done and I have installed Jenkins on my master and want to run my ranorex test on my slave machine. All files needed for running ranorex scripts are present on my slave. When the job from the master runs, it gives error
[2019/11/18 17:04:51.686][Debug ][Logger]: Console logger starting.
[2019/11/18 17:04:51.845][Failure][TestSuite]: This operation requires an interactive window station
[2019/11/18 17:04:51.858][Debug ][Logger]: Console logger stopping.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
i tried workarounds like going to Jenkins serve and selection option of user interaction.
If i only have bat file on slave of copying one folder to another and if i trigger job from master, it works. So master slave configuration does not have issue. Issue is running Ranorex GUI Test on Slave.
Jenkins needs to be running as an application not a service (which is default). Services cannot show anything with a GUI nor interact with anything with a GUI.
Disable the Jenkins service
Run Jenkins via Command Line java -jar jenkins.war
For a more detailed guide, check out the Infrastructure section of the Ranorex Jenkins integration blog.

Run first command on Jenkins Server and second command on the slave?

I have a requirement like I want to execute a script first on the Jenkins Server and the second script on the slave. Is it possible?
The server is up on a Ubuntu machine - the first script will setup the jobs html log file and the second script will run the actual test and stores the log at the end. I need to pass the env variables set by Jenkins to the second script. How can it be done?
Also, Is it possible to send the env variables set in Jenkins Server during run time to the slave and set the same in the slave?

Jenkins Jobs are not loading while starting it from CLI

I have setup a lot of jobs while Jenkins is running as windows service.When i try to start Jenkins from command line , none of the jobs are showing up.
Can some one let me know how to make sure all jobs are loaded when i start Jenkins from CLI on windows machine.
Make sure you have the same Jenkins home directory when you run it from CLI.
You can use JENKINS_HOME variable to control that:
set JENKINS_HOME=C:/myJenkins
java -jar jenkins.war

Execute Shell script from workspace on remote machine after build successful (Jenkins)

The scenario is - I have a job A which runs my ant script and packages the artifact's for me.
I am also using parametrized Triggered plug in to Trigger my "Job B" which will deploy my artifact on remote machine.
The job A is working fine and also Job B.
The tasks that i have to perform with Job B are
GIT checkout (which contains my deployment scripts) (successfully doning).
Copying artifacts from previous build to Remote machine. (successfully doing)
Run shell script on remote machine(script present in workspace folder )- Facing issues.
I browsed various plug ins for the same but no one is allowing me to run shell script after , "SCP to remote machine" which is present in Post build action.
I would like to execute the same sequence, however if you guys have any other suggestions please share.
Thanks in Advance.!
As part of Publish Over SSH Plugin, you can execute a script after the files had been copied over.
Under Post-build Actions
Add Send build artifacts over SSH
Select a preconfigured server (done in global configuration)
Select files to copy from workspace
Enter Exec command
If one of the files you copy is your shell script, you can enter it here as an "exec command"
To solve my query i used Jenkins SSH Plugin. This provides a configuration tab where i can add multiple hosts and after that used them in my job level configuration.
Link to Plugin
you get privilege to execute shell script on remote host as pre-build step or post build step.
updated the path of publish over ssh it worked for me

Executing windows command in Jenkins

I'm running Jenkins as Windows service on my PC. I'm trying to learn to use it. For a dummy job, one of the build step is Execute Windows batch command with the following command
JLink -ip 10.12.1.234
When I build the job on Jenkins I get a build error saying JLink is not recognized as internal or external command, operable program or batch file. When I run the command from a command prompt, it runs without any problem. Windows path has been set to the path where JLink is installed. Should I be configure anything additionally in Jenkins?
Try putting the fully qualified path (or an environment variable) of the command in Configure Project. Your user must be different from jenkins service, which runs as system

Resources