拷貝文件 xcopy
script{
bat "xcopy LocalBuilds\\Engine\\Windows ${params.DeployDir}\\${params.branch} /y /e /i /q"
}
- 使用
bat
進行${params.xxx}
參數傳遞時,需要使用script{}
包裝
dir("${params.DeployDir}")
{
withCredentials([usernamePassword(credentialsId: 'git-pass-credentials-ID', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
bat """
git add .
git config --global user.email "${GIT_USERNAME}@xxx.com"
git config --global user.name "${GIT_USERNAME}"
git commit -m"[Jenkins] ${params.commitLog}"
git push https://${GIT_USERNAME}:${GIT_PASSWORD}@<REPO>
"""
}
}
- 當git倉庫使用雙因素驗證時
GIT_PASSWORD
需設置爲personal access token
- 使用
https://${GIT_USERNAME}:${GIT_PASSWORD}@<REPO>
時,如果賬號和密碼存在特殊字符需要轉義,如@
->%40