我想這個線程是很老,但這裏是我對其採取哈德森:
我決定去與點子,併成立了回購(痛苦得到工作,但好看eggbasket),其中哈德森自動上傳到一個成功的測試。這裏是我粗略和準備好的腳本,用於使用hudson config執行腳本,如:/var/lib/hudson/venv/main/bin/hudson_script.py -w $ WORKSPACE -p my.package -v $ BUILD_NUMBER,只需放入**/coverage.xml,pylint.txt和nosetests。XML的配置位:
#!/var/lib/hudson/venv/main/bin/python
import os
import re
import subprocess
import logging
import optparse
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s')
#venvDir = "/var/lib/hudson/venv/main/bin/"
UPLOAD_REPO = "http://ldndev01:3442"
def call_command(command, cwd, ignore_error_code=False):
try:
logging.info("Running: %s" % command)
status = subprocess.call(command, cwd=cwd, shell=True)
if not ignore_error_code and status != 0:
raise Exception("Last command failed")
return status
except:
logging.exception("Could not run command %s" % command)
raise
def main():
usage = "usage: %prog [options]"
parser = optparse.OptionParser(usage)
parser.add_option("-w", "--workspace", dest="workspace",
help="workspace folder for the job")
parser.add_option("-p", "--package", dest="package",
help="the package name i.e., back_office.reconciler")
parser.add_option("-v", "--build_number", dest="build_number",
help="the build number, which will get put at the end of the package version")
options, args = parser.parse_args()
if not options.workspace or not options.package:
raise Exception("Need both args, do --help for info")
venvDir = options.package + "_venv/"
#find out if venv is there
if not os.path.exists(venvDir):
#make it
call_command("virtualenv %s --no-site-packages" % venvDir,
options.workspace)
#install the venv/make sure its there plus install the local package
call_command("%sbin/pip install -e ./ --extra-index %s" % (venvDir, UPLOAD_REPO),
options.workspace)
#make sure pylint, nose and coverage are installed
call_command("%sbin/pip install nose pylint coverage epydoc" % venvDir,
options.workspace)
#make sure we have an __init__.py
#this shouldn't be needed if the packages are set up correctly
#modules = options.package.split(".")
#if len(modules) > 1:
# call_command("touch '%s/__init__.py'" % modules[0],
# options.workspace)
#do the nosetests
test_status = call_command("%sbin/nosetests %s --with-xunit --with-coverage --cover-package %s --cover-erase" % (venvDir,
options.package.replace(".", "/"),
options.package),
options.workspace, True)
#produce coverage report -i for ignore weird missing file errors
call_command("%sbin/coverage xml -i" % venvDir,
options.workspace)
#move it so that the code coverage plugin can find it
call_command("mv coverage.xml %s" % (options.package.replace(".", "/")),
options.workspace)
#run pylint
call_command("%sbin/pylint --rcfile ~/pylint.rc -f parseable %s > pylint.txt" % (venvDir,
options.package),
options.workspace, True)
#remove old dists so we only have the newest at the end
call_command("rm -rfv %s" % (options.workspace + "/dist"),
options.workspace)
#if the build passes upload the result to the egg_basket
if test_status == 0:
logging.info("Success - uploading egg")
upload_bit = "upload -r %s/upload" % UPLOAD_REPO
else:
logging.info("Failure - not uploading egg")
upload_bit = ""
#create egg
call_command("%sbin/python setup.py egg_info --tag-build=.0.%s --tag-svn-revision --tag-date sdist %s" % (venvDir,
options.build_number,
upload_bit),
options.workspace)
call_command("%sbin/epydoc --html --graph all %s" % (venvDir, options.package),
options.workspace)
logging.info("Complete")
if __name__ == "__main__":
main()
當涉及到部署的東西,你可以這樣做:用
pip -E /location/of/my/venv/ install my_package==X.Y.Z --extra-index http://my_repo
然後人們可以開發的東西:
pip -E /location/of/my/venv/ install -e ./ --extra-index http://my_repo
這玩意假設你有一個每個軟件包有一個setup.py和依賴關係的repo結構,然後你可以檢查出trunk並運行它。
我希望這可以幫助別人。
------更新---------
我添加epydoc的可以完美融入真的很好哈德森。只需添加的Javadoc到你的配置與HTML文件夾
注意PIP不支持-E標誌正確,這些天,所以你必須創建VENV分別
偉大的問題,我正在尋找類似的東西就在眼下。如果你走一條路線,你能和我們其他人分享你的經驗嗎? – 2008-10-22 15:02:34
不知道這是否是可用的,當你這樣寫:使用哈德森查克諾里斯插件進一步加強對你的東西的控制! – 2009-12-16 14:59:51
** 2011/2012年更新**:那些考慮Hudson的應該使用[Jenkins](http://jenkins-ci.org/),Hudson項目的開源延續(Hudson現在[由Oracle控制] (http://stackoverflow.com/questions/4973981/how-to-choose-between-hudson-and-jenkins)) – mindthief 2012-07-09 20:27:02