grgit:在build.gradle脚本中添加标记并将文件推送到远程分支
我正在尝试使用grgit添加git标记,提交并将文件推送到远程分支。以下是我正在尝试做的:grgit:在build.gradle脚本中添加标记并将文件推送到远程分支,git,gradle,build,build.gradle,Git,Gradle,Build,Build.gradle,我正在尝试使用grgit添加git标记,提交并将文件推送到远程分支。以下是我正在尝试做的: //Task to push updated build.info to remote branch task pushToOrigin { doLast { def grgit = Grgit.open(dir: ".") grgit.add(patterns: ['web/build.info']) grgit.tag.add( name: "Tag
//Task to push updated build.info to remote branch
task pushToOrigin {
doLast {
def grgit = Grgit.open(dir: ".")
grgit.add(patterns: ['web/build.info'])
grgit.tag.add(
name: "Tag3",
message: "Release of 3-${grgit.head()}",
force: true
)
grgit.commit(message: "Updating build.info")
//push to remote
grgit.push(remote:"${branch}", tags: true)
//grgit.push(remote:"${branch}")
//cleanup
grgit.close()
}
println "Completed task: pushToOrigin"
}
我注意到grgit.push(remote:${branch}),tags:true)
添加标记并将标记推送到remote,但不会推送我的暂存文件更改
但是,grgit.push(remote:${branch}”)
推送暂存文件更改,但不推送标记
我使用的是Gradle 5.3,grgit版本2.3.0
我还需要做些什么才能让这两种方法都起作用吗
谢谢。我找到了解决上述问题的方法。以下是我所做的:
task pushToOrigin {
doLast {
def grgit = Grgit.open(dir: ".")
grgit.add(patterns: ['web/build.info'])
grgit.commit(message: "Updating build.info")
//Push to remote
grgit.push(remote:"${branch}")
//Tag
tagName = "tag1"
grgit.tag.add(
name: tagName,
message: "Release of ${tagName}"
)
//Push
grgit.push(remote:"${branch}", refsOrSpecs: [tagName])
//cleanup
grgit.close()
}
}
注意:标记名是在pushToOrigin任务范围之外声明的全局变量