2015-08-15 41 views
0

我是GIT的新手......我有一個要求,我們需要從目錄中選擇幾個文件並使用shell腳本將這些文件推送到git存儲庫?任何人都可以幫我解決這個問題嗎?我們可以使用Jenkins自動化這個過程嗎? 也就是說,每當我們觸發jenkins作業時,應該根據某種文件格式選擇所需的文件並將其推送到GIT repo? 預先感謝您如何使用shell腳本自動將文件推送到git repo

+0

這的確很簡單。 Jenkins可以運行你在工作中選擇的任何腳本。只需寫一個腳本來處理你想要做的git的東西。 – Martin

回答

0

要回答這個標題的問題,這裏有一個小的bash的例子,將推動文件

#!/bin/bash 

# add files you want to push here 
# git add <stuff> 

git push 

馬丁的評論似乎一心一意說是詹金斯的阿里納斯,但可能是更適合於另外一個問題,除非你找到this有用

旁註:一個bash/git的樣板我找到有用的是這樣的:

#!/bin/bash 

function pushIt() { 
    # maybe some stuff before the push? 
    # if so, add it here 
    git push 
} 

# this is a convenient check for uncommitted changes, 
# a handy thing if the script's expected to grow 
if [ -z "$(git status --porcelain)" ];then 
    pushIt 
else 
    echo "Repo isn't clean, commit or stash your changes" 
fi 
相關問題