Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Jenkins to trigger and manage a series of import jobs. I want to put my import script in Github, and when Jenkins builds the job, it should (a) pull that version controlled script out of Github and (b) run the script.

The problem that I am running into is that I don't know how to reference the name of the script to run within the job. I'm assuming that source code is pulled into the workspace directory. Is that assumption correct? (If only there was documentation!)

Here's what I've done so far:

  1. Installed Jenkins (obviously) on my Windows Server (no, I didn't have a choice about that)
  2. Created a repository on my github account and put my code in it
    • It's public at https://github.com/mcholl/SARS-Import/
    • You'll see I have two scripts, roottest.py and omniture-video\test.py. The code there is under patent by Apple, I'm sure :)
    • The idea is that I would want to run roottest.py
  3. Installed the Github plugin
  4. Created a job as follows:
  5. Manually execute the job

What I get, however, is an error message that the file cannot be located. This is strange, because I assume the workflow would be "pull a local copy of source to the ...(Job)/workspace/ directory, then run the batch command in the context of the workspace directory.

Here's the full console output:

Started by user anonymous Building in workspace C:\Program Files (x86)\Jenkins\jobs\Testing Github Integration\workspace [workspace] $ cmd /c call C:\Windows\TEMP\hudson1966342425043540895.bat

C:\Program Files (x86)\Jenkins\jobs\Testing Github Integration\workspace>python roottest.py python: can't open file 'roottest.py': [Errno 2] No such file or directory

C:\Program Files (x86)\Jenkins\jobs\Testing Github Integration\workspace>exit 2 Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE

Obviously I was expecting to just see the results of my print statement in the console.

What did I mess up? And why isn't my script already there?

share|improve this question
    
Lets see the code from C:\Windows\TEMP\hudson1966342425043540895.bat are you using git pull? –  user160910 Aug 13 '13 at 17:25
    
Jenkins automatically creates then deletes it. You can see the full contents in the console output, however - it's the "python roottest.py" command I referenced above –  Affable Geek Aug 13 '13 at 17:34
    
roottest.py is not in your path. Do you see the file in the workspace directory or is that automatically deleted as well? When you run git pull you need to be in the local copy of the cloned repository I believe, it should then pull any new changes into the local repo. It is hard to help you when I cannot see any of the actual commands being run. –  user160910 Aug 13 '13 at 17:40
    
Did you follow these instructions for the github plugin wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin- ? Did you set the GIT_HOME environmental variable etc? –  user160910 Aug 13 '13 at 17:44
    
D'oh! One more reason to hate windows. Thank you - I think that may be the issue –  Affable Geek Aug 13 '13 at 17:46

1 Answer 1

For my build (on a Linux host), I do something like this (as a build step in Jenkins) to execute a build script out of the freshly-checked-out workspace:

Execute shell Command:

 sh -x $WORKSPACE/build/myproject.build

I presume it would work similar on Windows, except of course you would use \ rather than / and you're using python rather than sh to execute your script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.