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
Related
I have setup a Jenkins job to deploy our application to Jenkins. The build step runs a windows batch file on the slave machine which in turn invokes a powershell script to deploy our application to an on premise service fabric cluster. However, the job fails because it doesn't recognize Service Fabric commands. All other command work though.
Here is the content of the batch file that is invoked from Jenkins.
powershell -command "DeployRevCart.ps1 ; exit $LASTEXITCODE"
Below is the exception from slave machine
Running Connect-ServiceFabricCluster
The term 'Connect-ServiceFabricCluster' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Even this simplified batch command fails with same error.
powershell -command "Connect-ServiceFabricCluster"
However, if I run the script directly in the slave machine, everything works fine. So I appreciate any help in resolving the issue.
I have a console application that needs to be permanently running on the same machine on which I run Jenkins. After I build and publish the .exe file I need to run it but if I try to use bat "pathtofile\\filename.exe", the pipeline will wait for the process to finish, but it never will because the process is a socket server which keeps running and listening.
Is there a way to Run a Fire-and-Forget command to start the .exe?
Have you considered creating a Windows Service? If this is not an option, I would suggest using the /B flag of the start command. For example,
start /B yourapp.exe
will execute your app in the background, somewhat similar to Linux's yourapp & command form.
To check out all the options of the start command, you can type help start in a Command Line Window.
Jenkins gives guidance and examples on this for freestyle projects (but the principle should be the same for pipeline), see:
https://wiki.jenkins.io/display/JENKINS/Spawning+processes+from+build
For Windows, there are a number of options - using the at command (runs a job at specific time); creating a wrapper script to run your bat file; or creating a scheduled task (thus similar to the at command). I've used the schedule task approach (again for freestyle builds rather than pipeline).
I have a Jenkins job that successfully builds my project, now i am trying to push the build to remote Amazon EC2 server using the MsDeploy command as follows:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -allowUntrusted -source:contentPath="%WORKSPACE%\dist" -dest:auto,computerName="https://ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com:8172/MSDeploy.axd?site=Default Web Site",username="administrator",password="xxxxxxxxxxx",authtype="Basic",includeAcls="False"
This command is working from my local machine command prompt as well as from the Jenkins server command prompt but giving ERROR_USER_UNAUTHORIZED when ran as a Execute windows batch command build step from Jenkins Job. Below are the error details:
When i copy the password from the above formatted Msdeploy command from the Jenkins console output and try to remote into the respective server, it doesn't log me in. Whereas if i copy the password from else where say like notepad, word etc.. and try to remote into the server, its working. It looks like the problem is with the way Jenkins is formatting the Msdeploy command. Should i have to format it in a specific way or is there any specific order the arguments in the command has to be framed ?
I know there are other options like using the publish over ssh plugin in Jenkins, but wondering why it can't be achieved with a simple Msdeploy command.
I am using Jenkins and Ant to execute my Selenium tests. I would like to make a job that would do the following:
starts Selenium server
executes tests and
kills Selenium server after all tests are run.
I am able to start the Selenium server manually with the following command:
java -jar selenium-2.16.1\selenium-server-standalone-2.25.jar
But I cannot find a Jenkins plugin that would do the start/stop for me. All I can find are some Selenium reporting plugins.
Not sure if there is a plugin, but you can just run the launch and kill commands via the Jenkins job.
Under Build, if you add an Execute shell build step, you can run your commands from there.
Note - The path to the selenium server is relative to the current work directory.
Looking at your error trace, looks like you are running this on a windows PC. you need to be running this as a "execute windows batch command" then run java -jar selenium-2.16.1\selenium-server-standalone-2.25.jar Assuming that you have your jar file on the workspace. or you beed to point it at the right path
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.