赞
踩
出现的问题:
出现问题的代码如下:
- def cherry_pick() {
- String cherryPickCommitId = CHERRY_PICK_COMMITID
- String cherryPickBranch = CHERRY_PICK_BRANCH
- echo "cherryPickBranch = ${cherryPickBranch}"
- echo "cherryPickCommitId = ${cherryPickCommitId}"
- String[] str;
- str = cherryPickCommitId.split(' ');
- echo "cherryPickCommitId : "
-
- for( String values : str ) {
- println(values)
-
- int patch_sets_number = sh( returnStdout: true, script: "ssh -p 29418 user@git.***.com gerrit query --format=JSON --patch-sets change:${values} | sed -n '1p' | jq '.patchSets' | grep number | wc -l")
- echo "patch_sets_number=${patch_sets_number}"
- int patch_sets_latest = patch_sets_number - 1
- echo "patch_sets_latest=${patch_sets_latest}"
- def refs_change = sh( returnStdout: true, script: "ssh -p 29418 user@git.***.com gerrit query --format=JSON --patch-sets change:${values} | sed -n '1p' | jq '.patchSets[$patch_sets_latest].ref' | sed 's/\"//g'")
- echo "patch_sets_latest = ${patch_sets_latest} refs_change = ${refs_change}"
- sh "git fetch idb ${refs_change}:${values}"
- }
- }
解决:将获取jsonl里的分支名后删除换行符就可以了
def refs_change = sh( returnStdout: true, script: "ssh -p 29418 aiot-robot@git.xiaomi.com gerrit query --format=JSON --patch-sets change:${values} | sed -n '1p' | jq '.patchSets[$patch_sets_latest].ref' | xargs echo -n | sed 's/\"//g'")
删除换行符的操作,最简单的是:
echo "55555" | xargs echo -n
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。