新项目配置
新項目配置
配置
EditorConfig
CHANGELOG
代碼管理
git
需要定義.gitignore,忽略提交目錄和文件
node_modules/ bower_components/ .DS_Store .idea代碼檢查
eslint
# 初始化 $ eslint --init # 可以選擇流行的eslint配置或者回答問題自定義配置生成.eslintrc文件 # 還可以新建.eslintignore忽略文件集成構建
jenkins
命令
$ sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist $ sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist使用
配置Github插件
jenkins web端平臺: 系統管理 >> 系統設置 >> GitHub Plugin Configuration
github上用戶: Settings >> personal access tokens >> 新建
勾選給Jenkins的訪問權限,Github plugin的幫助信息里說要admin:repo_hook、repo和repo:status權限,其實repo:status是包含在repo里的。 點擊Generate token創建一個token
復制這個token,回到Jenkins點擊Add按鈕
選擇Secret text,粘貼token,添加描述,點擊添加。Credentials中選擇剛才新建的。
點擊Verify credentials測試token,顯示Credentials verified for user xxx, rate limit: xxxx,說明配置完成了,這樣你的Jenkins就具有訪問你的github的權限了。
新建項目
創建一個freestyle任務
填寫項目的git地址, eg. https://github.com/your_name/...
添加github用戶和密碼
選擇githubweb源碼庫瀏覽器,并填上你的項目URL,這樣每次構建都會生成對應的changes,可直接鏈到github上看變更詳情
構建觸發器
勾選Build when a change is pushed to GitHub,這樣該倉庫的每一次push或者pull request都會觸發build
隨后配置構建環境、構建步驟和構建后步驟
安裝了Github Plugin之后在構建步驟和構建后操作會多兩個設置,用于在構建時和構建后同步構建狀態到Github的,后面有效果圖
配置Github倉庫的Webhook
倉庫的創建人在倉庫的Settings >> Webhooos & services添加
我們只需要push事件觸發就可以了,選中Just the push event
點擊Add webhook
yes,與github集成的Jenkins CI環境就配置好了
每次push都會觸發一次build,pull request的話還會在該界面直接顯示build結果
總結
- 上一篇: jenkins产生503错误的解决方法
- 下一篇: 杭州找Android工作的点点滴滴