Jenkins Pipeline 常用操作

手动拉取 Git/Svn 仓库源码

说明:使用 Pipeline 自带的 git,svn 以及 checkscm 命令会将源码仓库加入监控,当不想使用这个特性时,需要手动进行源码拉取

//git sample
withCredentials([usernamePassword(credentialsId: '37813d64-15e9-4a3c-9646-a5bfe2bd44fd', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
	sh 'git clone http://${GIT_USERNAME}:${GIT_PASSWORD}@${your_git_project_location}'
}

//svn sample
withCredentials([usernamePassword(credentialsId: '87cd2e0d-2e81-4735-b881-b49b4302bc99', passwordVariable: 'SVN_PASSWORD', usernameVariable: 'SVN_USERNAME')]) {
	sh 'svn co ${your_svn_project_location} . --username ${SVN_USERNAME} --password ${SVN_PASSWORD}'
}

提交更改至 Git/Svn 仓库

说明:发布至源码仓库时常用的功能

//git sample
sh '''
	git add --all
	git commit -am "$commit"
	git push origin master
	git tag -a "$tagname" -m "$commit"
	git push origin $tagname
'''

//svn sample
sh '''
	svn st | awk '{if ( $1 == "?") { print $2}}' | xargs -r svn add
	svn st | awk '{if ( $1 == "!") { print $2}}' | xargs -r svn rm
	svn commit -m "$commit"
	svn cp . ${your_svn_project_location}/tags/${tagname}  -m "$commit"
'''

写邮件

说明:略

mail (
	to: 'somebody@company.cn,nobody@company.cn',
	cc: 'somebody@company.cn',
	charset: 'UTF-8',
	mimeType: ' text/plain', 
	subject: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - SUCCESS!", 
	body: """
${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - SUCCESS:
Check console output at ${env.BUILD_URL} to view the results.
	"""
)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值