Running FTP through Jenkins on windows server 2012 - jenkins

I have installed Jenkins in our server successfully, and we can run configure and run jobs.
I want to run a Windows Batch Command on a Jenkins job, that should download some files through FTP. Initially I had some issues with FTP as I was able to connect to the server, but couldn't download files or list them, as FTP was unable to establish a data channel because of the server's firewall configuration.
I was able to fix this issue, opening ports to the FTP executable, and I was finally able to download the files from command line.
Now I want to make the same operation I'm running on command line, but in a Jenkins job.
The problem is that once I try to make a wget or ls, the job stalls and nothing happens. This behavior is similar to what I experienced in command line before opening ports, but I can't tell if its the same issue as Jenkins is not giving any feedback (on command line I could see the line "150 File status okay; about to open data connection.", Jenkin's console is only displaying the commands sent with FTP, but not the FTP response).
I have tried applying the same firewall configuration as the one applied to the FTP executable, to the Jenkins executable and service. No go.
I also changed the user that launches the Jenkins service, so it is launched by an administrator account. But it's just not working.
Anyone has any idea of whats going on?

Instead of using "Execute Windows Batch Command", I executed the FTP command through a "Execute shell", and the process completes correctly.

Related

Unable to open GUI Application through Jenkins

I'm new to Jenkins, I've created a Jenkins freestyle job used necessary plugins to invoke desktop application. When I execute the job with user credentials, I cannot see the application but application got up and logged on with user credentials. I'm doing GUI Automation which causes failures all the times when I try to run the job.
I created a batch file on HOST, calling the batch file through Jenkins. I have tried injecting the environment for job. I have enabled interactive services and Jenkins-slave on HOST machine. I tried to change NT/System user to Specific user. I enabled interactive services in both conditions. I'm not sure what I'm missing here. Do I need to install anything else, so far I have Jenkins-slave.exe on my HOST, I managed to generate executable Jar file using that.
Any help on this will be appreciated.
I'm calling the batch file, Jenkins cannot find the application opening apparently, it returning error as None type Object(Python) as described in screenshot.errors on Jenkins Job execution
I had a similar issue when I was trying to run Selenium UI Test on Windows Slave.
When the Slave is connected to Windows as a Service, then it does not bring up the application in foreground. It runs only in background even if you enable the service to interact with the desktop.
I had to change my browser to headless browser and then my test cases were passed in background mode.
My Old Question

How to determine why an agent pool is offline in Azure dev-ops

I noticed that all of my builds suddenly got stuck. If I click the build I get the following error: All eligible agents are disabled or offline
When I check my agent pools I get the following:
How can I bring them online/determine why they are offline?
Try logging into the VM, and run the run.cmd from an elevated powershell prompt in your agent directory.
Source: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
Login to powershell.Navigate to the agent folder where it contains run cmd prompt and config cmd prompt.
Execute the following command
.\run.cmd
Check the date and time on your VM. If it's wrong, correct it.
Then run powershell as administrator and cd into the azagent folder that contains the run.cmd file (most likely C:\azagent\A4).
Execute the following command:
.\run.cmd
For me, issue was suddenly agents were reporting offline on the portal.
Restarted the agent service in the VM - didn't help
Removed config file also didn't help because logs were showing that dev.azure.com wasn't connecting
Simply just restarting VM helped, but still couldn't able to find the cause.
The VM that host the build agents can have a auto shut down time. Make sure your build vm is running by going to Virtual machines in the azure portal
My agent stopped going live when I updated our Azure Devops to the latest version 2019.1.3 iirc.
To solve this I did the following:
Went to services.msc on the agent machine. Stopped the existing service.
Went to agent folder and removed the existing configuration via "config.cmd remove"
Downloaded latest agent code from the Azure Devops Agent Pools portal page.
Replaced contents of old agent with new agent files.
Went back to agent folder and configured a new agent via "config.cmd". Told it to start as a service.
Voila! Service back running again.
One of my Azure agents started showing as offline. As a test, I ran curl https://dev.azure.com/{organization} and got back an error "curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed".
I fixed the issue by downloading IISCryptoCli.exe from https://www.nartac.com/Products/IISCrypto/Download and then running "IISCryptoCli.exe /template default /reboot".
I solved this by connecting to the agent via Remote Desktop Connection and running the "Run Puppet Agent" application.
Please check the agent from agent tab under releases.
There should be a server listed for the agent under agent tab.
Now connect to that server and check weather the agent batch file or cmd window is open or not.(this agent for is the same file which is downloaded while configuring the agent.if you are struggling to find the file then follow new agent steps and download zip again and search with that file name.)
Now open the(filename -run) file on that server with admin right if it is already not running. This will make agent online in devops portal.
Now check the agent tab again in devops portal under releases.
This

Jenkins perforce triggered build on windows?

I feel totally in the dark, and hope you guys can help.
So I have a jenkins server setup connect to p4v and everything running smoothly.
I can trigger the builds on jenkins manually without any problems.
Now however I'd like to setup so Jenkins (using the perforce plugin) acually polls from perforce everytime I submit something new in a specific folder.
This seems fairly straightforward running on linux, just adding a script file in perforce and a perforce trigger to run that file using curl to send a message to jenkins to start the build.
However i'm running windows, and I dont find any information about how to solve this particular problem on windows. Anyone, to help?
The main problem seems to be that all tutorials I find on this uses a .sh script which isnt run in windows, I wonder if there is some other way to do this in windows?
I managed to solve this by using the following Jenkins plugin:
https://wiki.jenkins.io/display/JENKINS/Build+Token+Trigger+Plugin
and curl:
https://curl.haxx.se/
If someone else has the same issue here is the step by step process I went through to set it up on Windows.
In your Jenkins project, enable: Trigger builds remotely (e.g., from scripts)
Enter an Authentication Token, can be anything, ex: buildCode
On the command line as p4 admin enter: p4 triggers
In the trigger, file go to the bottom
Enter the actual p4 trigger: SomeTriggerName change-commit //DepotLocationToTriggerOn/... %//DepotLocationOfScriptToBeTriggered/trigger.bat%
Observe: When the batch file to be run in the trigger is in a depot path it must be surrounded by %
Submit the trigger.bat to p4 in the choosen location. The batch file need to contain the following code C:\curl-7.60.0-win64-mingw\bin\curl.exe -u userID:APIToken JenkinsIP/job/TestJob/build?token=buildCode
Curl must be in that specific folder on the p4v server machine.
The userID and APIToken is found by going to the user drop down and enter Configure, then clicking API Token.
Hope this might help someone else with a similar problem :).

Push build from Jenkins to Amazon EC2 using Msdeploy.exe

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.

How to get a Jenkins slave to open a windows server session

I'm trying to get a Jenkins slave to open a session on a windows server.
Basically, What I'm try to achieve is:
Jenkins slave is running as a service on a windows 2003 server. When master calls slave, it will open a desktop session on the server and kick off an .exe that will perform GUI testing
What I have done:
Jenkins node created (Node A). Dumb slave. Remote FS root set to path on Windows 2003 server. ("C:\Jenkins\Node"). Launch method Java Web Start
Slave 'Node A' installed from Jenkins master using Java Web Start on windows 2003 server
Jenkins slave now running as a service on server
Jenkins project created and 'Restrict where this project can be run' is set to 'Node A'
Project windows batch command 'C:\GUITest.exe'
When I build the project in Jenkins I was expecting that the slave would be able to open a session and run C:\GUITest.exe. But, I'm missing something.
Anyone any ideas, or know if it is possible (plugins I may need ??)
Any advise / direction much appreciated.
Looks like you want to run GUI test on windows session. It won't work if you run Jenkins Slave as service, you have to run JNLP agent on your windows server. Also if you want to run in unattended mode, meaning that the windows remote session would be disconnected, you need some other setup as well. Please provide more information on what you are trying to do.
You must ensure that whatever process runs the GUI tests (might be a java / cmd / ssh process if you're connected to Jenkins) is not running on session 0 as it won't have access to Desktop and the Windows UI in general. I was in a similar situation and running the same process as a scheduled task instead of service solved it for me.

Resources