I have a stage in my pipeline like below:
stage("Pre Flight Checks") {
steps {
echo 'using the message count externally'
script {
// Execute the shell command and assign the result to an environment variable
def messageCount = sh(script: "git rev-list origin/${env.DEV_BRANCH_NAME}..origin/${env.BRANCH_NAME} --oneline | wc -l", returnStdout: true).trim()
env.message_count = messageCount
}
echo "message_count: ${env.message_count}"
preFlightChecks()
}
}
I have defined few validations in my dsl lib function preFlightChecks() to run some checks. Here is the problem i am getting:
13:35:52 + git rev-list origin/develop..origin/release_10122024_1 --oneline
13:35:52 fatal: ambiguous argument 'origin/develop..origin/release_10122024_1': unknown revision or path not in the working tree.
13:35:52 Use '--' to separate paths from revisions, like this:
13:35:52 'git <command> [<revision>...] -- [<file>...]'
13:35:52 + wc -l
I am trying to identify the number of commit differences between the 2 branches and parse the logic based on that value.
while the same command works fine when i am running locally. works intermittently over the CI. How to understand this behaviour? i am clueless !! dear experts please provide your inputs.
git rev-parse origin/develop
andgit rev-parse origin/release_10122024_1
? If you get 2 IDs out of that (which would be quite a shocker), let us know.** 15:08:52 + git rev-parse HEAD~1 15:08:52 fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree. 15:08:52 Use '--' to separate paths from revisions, like this: 15:08:52 'git <command> [<revision>...] -- [<file>...]' 15:08:52 HEAD~1
** This happened on the same run. This is the main concerning thing. The git commands are behaving so flaky way.