Setting up Jenkins for Windows with GIT and SSH is a tricky thing. This is because there are multiple binaries for ssh, git, ssh-keygen, plink, windows users, different .ssh directories, differences in directory handling/paths (I'm looking at you "Program Files (x86)"!) etc. This is intended for a slave machine that can be used to build and test Visual studio projects, such as MFC applications. This can reveal the problems which can be reported back as development changes are put into place for other front end implementations (GNU/Linux OSX even WebGL etc.) Note: msysgit contains a full environment to build GIT ( I have not tried ). This also contains other unix utils GIT is a precompiled binary for the system ( I use this ) cygwin + git is a treacherous path that msysgit has solved. Avoid this. Be sure that the git, ssh, plink binaries from any such installations are not in the system PATH First step: GIT + SSHInstall PuTTYin C:\PuTTY (use windows installer to install everything) Install GIT in C:\Git and use plink.exe from PuTTY Adding to known_hosts Open a command window in C:\Users\<username>\ "C:\Git\bin\ssh.exe" -T <projectuser>@project.vislab.usyd.edu.au yes ls - to check that you are logged in (no PS1 on term) Test login again, so you don't have any prompt for new server "C:\Git\bin\ssh.exe" -T <projectuser>@project.vislab.usyd.edu.au Creating and setting up the ssh keys for automatic login "C:\Git\bin\ssh-keygen.exe" -t dsa Note: Do not use a passphrase, allow default folder of C:\Users\<username>\.ssh network copy the public key from C:\Users\<username>\.ssh\id_dsa.pub to project.vislab.usyd.edu.au: cat id_dsa.pub >> authorized_keys remove that key now (rm id_dsa.pub) Test the auto login, to make sure you don't have to enter password "C:\Git\bin\ssh.exe" -T <projectuser>@project.vislab.usyd.edu.au Enable ssh login for the system account (Windows 7 x64) Copy folder .ssh for system account on 64 bit system C:\Users\<username>\.ssh to C:\Windows\SysWOW64\config\systemprofile\.ssh By default, the Jenkins installer sets up Jenkins to run as a service, which runs as the “Local System account”, NOT your user account. IF the “Local System account” does not have SSH keys or known_hosts set up, “git clone” will fail. Testing the system account and GIT access can be done using PS tools (http://download.sysinternals.com/Files/PsTools.zip) (see guide website) Second step: JenkinsInstall the Jenkins native package for windows (Note you will need latest Java runtime) Visit http://localhost:8080 in a web browser Install the Git plugin {
} SSH credential should be setup {
Admin setup { Jenkins URL: use public address e.g. http://snow.vislab.usyd.edu.au:8080 System admin email: you@gmail.com SMTP server: smtp.gmail.com } Third step: Setting up the a new Jenkins job1) Source code management -> Git e.g. use the repos e.g. WOGL:
2) Click on Build Now 3) You can click on the status and the Build Console to view progress. 4) Be patient, even for small projects, the output will not show anything and will take a while. The first sign of success is seeing a .git folder e.g. C:\jenkins\workspace\wogl\.git Building in workspace C:\jenkins\workspace\wogl Cloning the remote Git repository Cloning repository ssh://john@project.vislab.usyd.edu.au/Groups/WOGL/wogl.git git --version git version 1.8.4.msysgit.0 (stalls around here...) Checking out Revision dcba94df4ab10735fe1bff4d1381acc192da0ee1 (origin/master) First time build. Skipping changelog. Finished: SUCCESS Fourth step: Building the projectWe are using Microsoft Visual Studio 2010, but Jenkins will use any means of command line parameters to start a build process. 1) Click "Add Build Step" -> "Execute windows batch command" 2) Add the custom build script. The last command will return the status wogl example: { call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 msbuild "C:\jenkins\workspace\wogl\windows\wogl\wogl\wogl.vcxproj" } Explanation: using the path to MSVS, setup the environment to use the developer tool "msbuild", then run msbuild on the project given it's full path as a .vcxproj file 3) Click "Save" 4) Build Now (cross fingers) Failed to buildThis is where the settings of the project come into play, comparing the environment of the IDE, with the cmd set environment that Jenkins uses. Cannot open include file: If you have set relative directories based on the solution directory i.e $(SolutionDir) then you might have to fiddle around. Check the build console to see the errors, and diagnose the issue by using a separate command window after modifying the project settings. It is easier to to change all these settings on another machine that has already been setup for development with git and can commit + push. This is because user/email config not setup on the Jenkins one, unless you go the PS tools path. Fifth step: TestingThis is entirely up to you. You can add another project that does certain tests, or append a tests script (batch file) to the build step so it is all the same process. e.g. wogl New Job -> wogl tests Execute Windows batch command echo "blah" > C:\Users\<username>\Documents\test.txt Build now Save |
Resources >