在項目中創建的根目錄中的文件composer.json添加 所有你需要
的pacakages { 「名稱」: 「amarjitsingh」, 「描述」: 「amarjitsingh」, 「許可證」: 「BSD -3-條款」, 「關鍵字」:[ 「框架」, 「ZF2」 ] , 「homepage」:「http://domain.com/」, 「require」:{ 「php」:「> = 5.5」, 「zendframework/zendframework」:「〜2.5」, 「phpoffice/phpword」:「dev-master」 , 「doctrine/doctrine-orm-module」:「0.7.0」, 「imag/Imagine」:「0.5。*」, 「zf-commons/zfc-user」:「dev-master」 } 「自動加載」:{ 「psr.0」: 「/模塊」 }
}
運行 'composer install
' 安裝這些軟件包。
設置git的機器 上,如果你正在使用Ubuntu,你可以使用如下因素命令
sudo易於得到更新 命令和apt-get安裝的git
設置設置GIT最多的Git
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
檢查的配置列表
git config --list
一旦你已經安裝GIT則c
cd /path/to/your/project
。一旦你安裝了打包文件,在打印文件 root
中創建一個'.gitignore
'文件,並在其中添加'vendor'
。
git init
git remote add origin https://[email protected]/username/zf2ci.git
適用以下命令使用雲您可以使用AWS來添加,提交和推文件
git add .
git commit -m 'Initial commit with contributors'
git push -u origin master
git pull
。我使用數字海洋
1創建droplet
2.name它如你所願,在mycase是zf2ci 3.選擇軟件包 4.選擇OS我CAS EIS的Ubuntu 14.04 5.在應用程序選項卡選擇LAMP 6完成後,您將獲得IP地址,用戶名和密碼。 7.登錄的IP通過使用油灰 8.用戶root
9.密碼pass
10.一旦你進入它會提示決定是否改變密碼 11.轉到Web根例如/var/www/html
12.安裝GIT 13. apt-get install git
14.克隆回購 15. git clone https://[email protected]/username/zf2ci.git
16.在該機器上安裝作曲家
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
注意:如果上述失敗由於權限,與須藤再次運行中壓線。 快速複製粘貼的版本包括須藤:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
- 轉到應用程序路徑
/var/ww/html/zf2ci
- 運行「
composer install --no-dev
」我們沒有開發選項becuasae我們只安裝以及安裝它應用程序服務器上測試代碼
第三步
創建詹金斯服務器 1.設置另外的液滴爲詹金斯 2.圖像Ubuntu的 3.安裝燈泡 安裝Jenkns
安裝詹金斯 之前,我們可以安裝詹金斯,我們必須重點和源列表添加到貼切。這分兩步完成,首先我們將添加密鑰。
1.1
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
其次,我們將創建一個詹金斯源列表。現在
1.2
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
1.3 ,我們只需要更新APT的緩存之前,我們就可以安裝詹金斯。
apt-get update
1.4 作爲緩存已經更新,我們可以繼續安裝詹金斯。請注意,Jenkins有大量的依賴關係,因此可能需要一些時間來安裝它們。
apt-get install jenkins
1。5打開與端口8080 如http://127.0.0.1:8080
1.6 IP安裝git的詹金斯服務器上
sudo apt-get update
sudo apt-get install git
1.7安裝作曲家
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
1.8使用戶認證
1.9 enable bitbucket plugin
詹金斯 1.9.1 Manage Jenkins->Manage Plugins->Bitbucket Plugin->download
並安裝 1.9.2 創造就業 創建求職> 項目名稱(例如。 zf2ci) - > 源代碼管理(git)提供ssh url([email protected]:username/zf2ci.git
) - > 分支到內置(*/master)這是每次任何用戶提交併合併代碼的主分支的分支-Jenkins被調用
1.9.3 構建觸發 選擇的選項(建當chnage推),這將炒鍋時,我們就有點桶一個POST鉤
1.9.4 建設 - >執行shell
composer install
./vendor/bin/phpunit ./tests
個我們的測試坐在intests DIR
1.9.5 設置ssh key pair
登錄詹金斯Serevr通過膩子
su jenkins
cd
ls -la(check what is in the jenkins home directory)
ssh-kegen -t rsa (dsa by default but choose rsa key ,it is faster)
press enter(on path)
press enter(leave the pass phrase empty , the whole point here is to avoid passwords in the automated jobs)
pres enter
cd .ssh
ls -la
(你會發現id_rsa.pub
)文件中有
cat id_rsa.pub
(選擇所有和複製文件的內容)
1.9.6 轉到到位桶 開關回購zf2ci 轉到設置 點擊部署鍵 - >添加關鍵 添加標籤(詹金斯) 鍵*(粘貼id_rsa.pub的內容)的文件在這裏 保存鍵
summary
`zf2ci->settings->deployment keys->add key->type` label and paste id_rsa.pub key->save
1.9.7 寄存器POST鉤回購
Settings->
Integrations->
Hooks->
POST(search for POST Hook)->
Add the url /IP of the Jenkins Server) (`172.62.235.100:8080/bitbucket-hook/`)
(the body of the post contanis information about the repository, branch, list of recent commits, user)
1.9.8 登錄詹金斯服務器上詹金斯 1.9
su jenkinks
cd
cd .ssh
git ls-remote -h ssh://[email protected]:username/zf2ci.git HEAD
1.9.9 save
項目。10 在 添加下面的命令執行殼 - >命令 [rsync -y -vrzhe "ssh -o StrictMostKeyChecking=no" --exclude vendor/ . [email protected]:/var/www/html/zf2ci
(應用服務器)
ssh [email protected]<<EOF
cd /var/www/html/zf2ci
composer install --no-dev
EOF
吧,這樣我只需要確保,在構建過程中,composer.lock文件複製到該位置,並執行作曲家安裝以檢查新軟件包。我可能確實能夠在構建文件中僅使用環境開關 –