拷贝文件 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