Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Windows instance on EC2 from Jenkins?

Tags:

I have configured my Jenkins to execute a Linux instance on AWS EC2. This works absolutely fine and I am able to invoke Linux instances on EC2 via Jenkins. (Installed a couple of plugins; settings; creating custom Linux AMI etc.).

I want to run a Windows instance on EC2 via Jenkins. I have already setup a custom Windows AMI with Java installed and Winrm configured; a security group that allows TCP on port 445 and 5985; for SMB and Winrm respectively (https://issues.jenkins-ci.org/browse/JENKINS-4995).

I am able to invoke this Windows instance from Jenkins, but it never connects(just continues the loop "Connecting to ec2-54-191-40-110.us-west-2.compute.amazonaws.com(54.191.40.110) with WinRM as. Waiting for WinRM to come up. Sleeping 10s."

Please help me with the same.

like image 772
vintrojan Avatar asked Jun 24 '16 10:06

vintrojan


2 Answers

you will need to create a new AMI and change the execution policy on it.

  1. create a new machine from the AMI you mentioned above.

  2. login to it and run the following from the cmd

    powershell Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
    
  3. take a new image.

  4. configure the new AMI in jenkins.

and you are good to go.

like image 81
yogev Avatar answered Sep 28 '22 02:09

yogev


I ran into similar problem. However in my case it turned out that I had windows firewall enabled and it was blocking port 445 which is required before the winrm connection as revealed by plugin source code: https://github.com/jenkinsci/ec2-plugin/blob/0278dd242a554ff200144b813122505f6d8dcd0e/src/main/java/hudson/plugins/ec2/win/WinConnection.java Look at the ping() method

like image 40
Maruthi Avatar answered Sep 28 '22 04:09

Maruthi