Issue
I have deleted the branch at remote with name release-12423
; however the below pipeline still checkout on release branch which does not exist on remote.
Expected:
I want the pipeline to fail or not run if the release branch does not exist on remote repo. The pipeline should successfully run only when the release branch exists on remote.
Below is the environment details along with the sample pipeline and the output. I am not sure if I am missing some parameter configuration.
Jenkins setup:
Jenkins: 2.462.1
OS: Linux - 5.15.0-116-generic
Java: 17.0.12 - Ubuntu (OpenJDK 64-Bit Server VM)
---
Pipeline
pipeline {
agent { label 'master' }
stages {
stage('Fetch') {
steps {
checkout(
changelog: false,
poll: false,
scm: scmGit(
branches: [[
name: 'refs/heads/release-*'
]],
extensions: [
cloneOption(
noTags: false,
reference: '',
shallow: false,
timeout: 90
),
pruneStaleBranch(),
cleanBeforeCheckout()
],
userRemoteConfigs: [[credentialsId: 'sample-github-token', url: 'https://github.com/testxxxxx.git']]
)
)
sh 'git branch -a'
}
}
}
post {
always {
echo 'Deployment Status: ' + currentBuild.result
cleanWs()
}
}
}
Console Output
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Fetch)
[Pipeline] checkout
17:20:37 The recommended git tool is: NONE
17:20:37 using credential sample-github-token
17:20:37 Cloning the remote Git repository
17:20:37 Cloning repository https://github.com/testxxxxx.git'
17:20:37 > git init /var/lib/jenkins/workspace/sample # timeout=10
17:20:37 Fetching upstream changes from https://github.com/testxxxxx.git'
17:20:37 > git --version # timeout=10
17:20:37 > git --version # 'git version 2.25.1'
17:20:37 using GIT_ASKPASS to set credentials This is the token for Jenkins to access GitHub repositories. This is the "personal access token"
17:20:37 > git fetch --tags --force --progress -- https://github.com/testxxxxx.git' +refs/heads/*:refs/remotes/origin/* # timeout=90
17:20:38 > git config remote.origin.url https://github.com/testxxxxx.git' # timeout=10
17:20:38 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
17:20:38 Avoid second fetch
17:20:38 Seen branch in repository origin/2021-11-18
17:20:38 Seen branch in repository origin/develop
17:20:38 Seen branch in repository origin/feat/test-stage
17:20:38 Seen branch in repository origin/master
17:20:38 Seen branch in repository origin/test/actions
17:20:38 Seen 5 remote branches
17:20:38 > git show-ref --tags -d # timeout=10
17:20:38 Checking out Revision 1c35fba8216900502876acb2ee37b69aa477bc77 (origin/release-2.5.3-202124521)
17:20:38 > git config core.sparsecheckout # timeout=10
17:20:38 > git checkout -f 1c35fba8216900502876acb2ee37b69aa477bc77 # timeout=10
17:20:38 Commit message: "Update test2.yaml"
[Pipeline] echo
17:20:38 Fetch is done
[Pipeline] sh
17:20:39 + git branch -a
17:20:39 * (HEAD detached at 1c35fba)
17:20:39 remotes/origin/2021-11-18
17:20:39 remotes/origin/develop
17:20:39 remotes/origin/feat/test-stage
17:20:39 remotes/origin/master
17:20:39 remotes/origin/test/actions
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
17:20:39 Deployment Status: SUCCESS
[Pipeline] cleanWs
17:20:40 [WS-CLEANUP] Deleting project workspace...
17:20:40 [WS-CLEANUP] Deferred wipeout is used...
17:20:40 [WS-CLEANUP] done
Plugin Details:
analysis-model-api:12.4.0
ansicolor:1.0.4
ant:511.v0a_a_1a_334f41b_
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
apache-httpcomponents-client-5-api:5.3.1-110.v77252fb_d4da_5
asm-api:9.7-33.v4d23ef79fcc8
aws-credentials:231.v08a_59f17d742
aws-java-sdk:1.12.753-463.v071a_97315959
aws-java-sdk-api-gateway:1.12.753-463.v071a_97315959
aws-java-sdk-autoscaling:1.12.753-463.v071a_97315959
aws-java-sdk-cloudformation:1.12.753-463.v071a_97315959
aws-java-sdk-cloudfront:1.12.753-463.v071a_97315959
aws-java-sdk-codebuild:1.12.753-463.v071a_97315959
aws-java-sdk-codedeploy:1.12.753-463.v071a_97315959
aws-java-sdk-ec2:1.12.753-463.v071a_97315959
aws-java-sdk-ecr:1.12.753-463.v071a_97315959
aws-java-sdk-ecs:1.12.753-463.v071a_97315959
aws-java-sdk-efs:1.12.753-463.v071a_97315959
aws-java-sdk-elasticbeanstalk:1.12.753-463.v071a_97315959
aws-java-sdk-elasticloadbalancingv2:1.12.753-463.v071a_97315959
aws-java-sdk-iam:1.12.753-463.v071a_97315959
aws-java-sdk-kinesis:1.12.753-463.v071a_97315959
aws-java-sdk-lambda:1.12.753-463.v071a_97315959
aws-java-sdk-logs:1.12.753-463.v071a_97315959
aws-java-sdk-minimal:1.12.753-463.v071a_97315959
aws-java-sdk-organizations:1.12.753-463.v071a_97315959
aws-java-sdk-secretsmanager:1.12.753-463.v071a_97315959
aws-java-sdk-sns:1.12.753-463.v071a_97315959
aws-java-sdk-sqs:1.12.753-463.v071a_97315959
aws-java-sdk-ssm:1.12.753-463.v071a_97315959
aws-secrets-manager-secret-source:1.72.v61781b_35c542
bootstrap5-api:5.3.3-1
bouncycastle-api:2.30.1.78.1-248.ve27176eb_46cb_
branch-api:2.1178.v969d9eb_c728e
build-timeout:1.33
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.2.0
cloudbees-folder:6.942.vb_43318a_156b_2
cobertura:1.17
code-coverage-api:4.99.0
command-launcher:115.vd8b_301cc15d0
commons-compress-api:1.26.1-2
commons-lang3-api:3.14.0-76.vda_5591261cfe
commons-text-api:1.12.0-129.v99a_50df237f7
conditional-buildstep:1.4.3
configuration-as-code:1836.vccda_4a_122a_a_e
configuration-as-code-groovy:1.1
configuration-as-code-secret-ssm:1.0.1
copyartifact:749.vfb_dca_a_9b_6549
coverage:1.16.1
credentials:1371.vfee6b_095f0a_3
credentials-binding:681.vf91669a_32e45
dark-theme:479.v661b_1b_911c01
dashboard-view:2.508.va_74654f026d1
data-tables-api:2.0.8-1
display-url-api:2.204.vf6fddd8a_8b_e9
durable-task:568.v8fb_5c57e8417
echarts-api:5.5.0-1
eddsa-api:0.3.0-4.v84c6f0f4969e
email-ext:1814.v404722f34263
embeddable-build-status:487.va_0ef04c898a_2
file-operations:266.v9d4e1eb_235b_a_
font-awesome-api:6.5.2-1
forensics-api:2.4.0
gcloud-sdk:0.0.3
generic-webhook-trigger:2.2.2
git:5.3.0
git-client:5.0.0
git-parameter:0.9.19
github:1.39.0
github-api:1.321-468.v6a_9f5f2d5a_7e
github-autostatus:3.6.2
github-branch-source:1793.v1831e9c68d77
google-api-client-plugin:2.0-1.20.0
google-login:109.v022b_cf87b_e5b_
google-metadata-plugin:0.5
google-oauth-plugin:1.330.vf5e86021cb_ec
google-storage-plugin:1.360.v6ca_38618b_41f
gradle:2.12
groovy:457.v99900cb_85593
gson-api:2.11.0-41.v019fcf6125dc
instance-identity:185.v303dc7c645f9
ionicons-api:74.v93d5eb_813d5f
jackson2-api:2.17.0-379.v02de8ec9f64c
jacoco:3.3.6
jakarta-activation-api:2.1.3-1
jakarta-mail-api:2.1.3-1
javax-activation-api:1.2.0-7
javax-mail-api:1.6.2-10
jaxb:2.3.9-1
jdk-tool:80.v8a_dee33ed6f0
jjwt-api:0.11.5-112.ve82dfb_224b_a_d
job-dsl:1.87
joda-time-api:2.12.7-29.v5a_b_e3a_82269a_
jquery3-api:3.7.1-2
json-api:20240303-41.v94e11e6de726
json-editor-parameter:48.v1ca_7f47e3d48
json-path-api:2.9.0-58.v62e3e85b_a_655
junit:1284.vf75d778f98c5
ldap:725.v3cb_b_711b_1a_ef
lockable-resources:1255.vf48745da_35d0
mailer:472.vf7c289a_4b_420
matrix-auth:3.2.2
matrix-project:832.va_66e270d2946
metrics:4.2.21-451.vd51df8df52ec
mina-sshd-api-common:2.13.1-117.v2f1a_b_66ff91d
mina-sshd-api-core:2.13.1-117.v2f1a_b_66ff91d
newrelic-deployment-notifier:1.11
nvm-wrapper:0.1.7
oauth-credentials:0.653.v14cf2088e950
okhttp-api:4.11.0-172.vda_da_1feeb_c6e
openJDK-native-plugin:1.8
pam-auth:1.11
parameterized-trigger:806.vf6fff3e28c3e
pipeline-aws:1.45
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-github-lib:61.v629f2cc41d83
pipeline-graph-analysis:216.vfd8b_ece330ca_
pipeline-graph-view:313.v1322ce83d680
pipeline-groovy-lib:727.ve832a_9244dfa_
pipeline-input-step:495.ve9c153f6067b_
pipeline-milestone-step:119.vdfdc43fc3b_9a_
pipeline-model-api:2.2205.vc9522a_9d5711
pipeline-model-definition:2.2205.vc9522a_9d5711
pipeline-model-extensions:2.2205.vc9522a_9d5711
pipeline-rest-api:2.34
pipeline-stage-step:312.v8cd10304c27a_
pipeline-stage-tags-metadata:2.2205.vc9522a_9d5711
pipeline-stage-view:2.34
pipeline-utility-steps:2.17.0
plain-credentials:183.va_de8f1dd5a_2b_
plugin-util-api:4.1.0
prism-api:1.29.0-15
remote-file:1.24
resource-disposer:0.23
role-strategy:743.v142ea_b_d5f1d3
run-condition:1.7
scm-api:696.v778d637b_a_762
scm-filter-branch-pr:148.v0b_5f06e8b_c84
script-security:1341.va_2819b_414686
slack:734.v7f9ec8b_66975
snakeyaml-api:2.2-121.v5a_68b_9300b_d4
snyk-security-scanner:4.1.0
sonar:2.17.2
ssh-agent:376.v8933585c69d3
ssh-credentials:343.v884f71d78167
ssh-slaves:2.973.v0fa_8c0dea_f9f
sshd:3.330.vc866a_8389b_58
structs:338.v848422169819
theme-manager:262.vc57ee4a_eda_5d
timestamper:1.27
token-macro:400.v35420b_922dcb_
trilead-api:2.147.vb_73cc728a_32e
variant:60.v7290fc0eb_b_cd
versionnumber:1.11
warnings-ng:11.4.0
workflow-aggregator:600.vb_57cdd26fdd7
workflow-api:1322.v857eeeea_9902
workflow-basic-steps:1058.vcb_fc1e3a_21a_9
workflow-cps:3922.va_f73b_7c4246b_
workflow-durable-task-step:1364.v2fd76fb_6fd41
workflow-job:1436.vfa_244484591f
workflow-multibranch:795.ve0cb_1f45ca_9a_
workflow-scm-step:427.v4ca_6512e7df1
workflow-step-api:678.v3ee58b_469476
workflow-support:920.v59f71ce16f04
ws-cleanup:0.46