Skip to content

Commit c47d218

Browse files
authored
[release] split git commands in sh steps with some labels (elastic#2264)
1 parent c3a87d8 commit c47d218

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

.ci/release/Jenkinsfile

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,21 @@ pipeline {
188188
def isMajor = env.RELEASE_VERSION.endsWith(".0.0")
189189
if (isMajor) {
190190
// major release, create '.x' branch
191-
sh(script: """
192-
git fetch origin ${RELEASE_TAG} # ensure remote tag is fetched for local checkout
193-
git checkout ${RELEASE_TAG}
194-
git checkout -b ${BRANCH_DOT_X}
195-
""")
191+
sh(label: "remote tag is fetched for local checkout", script: "git fetch origin ${RELEASE_TAG}")
192+
sh(label: "create .x branch from ${RELEASE_TAG}", script: """
193+
git checkout ${RELEASE_TAG} --force
194+
git checkout -b ${BRANCH_DOT_X} --force""")
196195
gitPush()
197196
input message: "This was a major version release. Please update the conf.yml in the docs repo before continuing", ok "Continue"
198197
} else {
199198
// minor release, force-update existing '.x' branch. any change applied to '.x' branch, for example to
200199
// fix doc or release notes should also have been applied to master/stable branch we are releasing from
201-
sh(script: """
202-
git fetch origin ${BRANCH_DOT_X} # ensure remote branch is fetched for local checkout
203-
git fetch origin ${RELEASE_TAG} # ensure remote tag is fetched for local checkout
204-
git checkout --track origin/${BRANCH_DOT_X}
205-
git reset --hard ${RELEASE_TAG}
206-
""")
200+
sh(label: "remote tag and branch are fetched for local checkout", script: """
201+
git fetch origin ${BRANCH_DOT_X}
202+
git fetch origin ${RELEASE_TAG}""")
203+
sh(label: "force-update .x branch from ${RELEASE_TAG}", script: """
204+
git checkout --track origin/${BRANCH_DOT_X} --force
205+
git reset --hard ${RELEASE_TAG}""")
207206
gitPush(args: "-f ${BRANCH_DOT_X}")
208207
}
209208
}
@@ -214,10 +213,8 @@ pipeline {
214213
dir("${BASE_DIR}") {
215214
// restore git state before updating .x branch, otherwise later external scripts will use
216215
// the version when the tag was created, which might not match the release branch state
217-
sh(script: """
218-
git fetch origin ${BRANCH_SPECIFIER} # ensure remote branch is fetched for local checkout
219-
git checkout --track origin/${BRANCH_SPECIFIER}
220-
""")
216+
sh(label: "remote branch is fetched for local checkout", script: "git fetch origin ${BRANCH_SPECIFIER}")
217+
sh(label: "restore to previous updating version", script: "git checkout --track origin/${BRANCH_SPECIFIER}")
221218
}
222219
}
223220
}

0 commit comments

Comments
 (0)