[JIRA] (JENKINS-43104) Declarative pipeline branch condition not working

1 view
Skip to first unread message

derek.smith@naveego.com (JIRA)

unread,
Mar 25, 2017, 12:48:02 PM3/25/17
to jenkinsc...@googlegroups.com
Derek Smith created an issue
 
Jenkins / Bug JENKINS-43104
Declarative pipeline branch condition not working
Issue Type: Bug Bug
Assignee: Unassigned
Attachments: Jenkinsfile
Components: pipeline
Created: 2017/Mar/25 4:47 PM
Priority: Minor Minor
Reporter: Derek Smith

I am working with a simple pipeline, just to get familiar with the system.  My pipeline is defined in the attached Jenkinsfile.  I can't seem to get the "Deploy" stage to work.  I am using the simple "when { branch 'master' }".  However I keep getting: (this is a single branch repo with a master branch).
Stage 'Deploy' skipped due to when conditional

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

derek.smith@naveego.com (JIRA)

unread,
Mar 25, 2017, 12:49:05 PM3/25/17
to jenkinsc...@googlegroups.com
Derek Smith updated an issue
Change By: Derek Smith
I am working with a simple pipeline, just to get familiar with the system.  My pipeline is defined in the attached Jenkinsfile.  I can't seem to get the "Deploy" stage to work.  I am using the simple "when \{ branch 'master' }".  However I keep getting: (this  *Stage 'Deploy' skipped due to when conditional*

NOTE: This
is a single branch repo with only a master branch ).
Stage 'Deploy' skipped due to when conditional
 

derek.smith@naveego.com (JIRA)

unread,
Mar 25, 2017, 12:51:01 PM3/25/17
to jenkinsc...@googlegroups.com
Derek Smith updated an issue
I am working with a simple pipeline, just to get familiar with the system.  My pipeline is defined in the attached Jenkinsfile.  I can't seem to get the "Deploy" stage to work.  I am using the simple "when \{ branch 'master' }".  However I keep getting: *Stage 'Deploy' skipped due to when conditional*


NOTE: This is a single branch repo with only a master branch

Jenkins Version: 2.51

Running on AWS Linux image. I followed this setup guide: [https://aws.amazon.com/getting-started/projects/setup-jenkins-build-server/]

 

derek.smith@naveego.com (JIRA)

unread,
Mar 25, 2017, 12:52:01 PM3/25/17
to jenkinsc...@googlegroups.com
Derek Smith updated an issue
I am working with a simple pipeline, just to get familiar with the system.  My pipeline is defined in the attached Jenkinsfile.  I can't seem to get the "Deploy" stage to work.  I am using the simple "when \{ branch 'master' }".  However I keep getting: *Stage 'Deploy' skipped due to when conditional*

NOTE: This is a single branch repo with only a master branch

Jenkins Version: 2.51

Pipeline Plug: 2.5

 

Running on AWS Linux image. I followed this setup guide: [https://aws.amazon.com/getting-started/projects/setup-jenkins-build-server/]

 

derek.smith@naveego.com (JIRA)

unread,
Mar 25, 2017, 12:53:01 PM3/25/17
to jenkinsc...@googlegroups.com
Derek Smith updated an issue
I am working with a simple pipeline, just to get familiar with the system.  My pipeline is defined in the attached Jenkinsfile.  I can't seem to get the "Deploy" stage to work.  I am using the simple "when \{ branch 'master' }".  However I keep getting: *Stage 'Deploy' skipped due to when conditional*

NOTE: This is a single branch repo with only a master branch

Jenkins Version: 2.51

Pipeline Plug Plugin Version : 2.5


 

Running on AWS Linux image. I followed this setup guide: [https://aws.amazon.com/getting-started/projects/setup-jenkins-build-server/]

 

andrew.bayer@gmail.com (JIRA)

unread,
Mar 28, 2017, 6:25:02 PM3/28/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Mar 28, 2017, 6:25:02 PM3/28/17
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Component/s: pipeline-model-definition-plugin
Component/s: pipeline

andrew.bayer@gmail.com (JIRA)

unread,
Mar 28, 2017, 6:27:05 PM3/28/17
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-43104
 
Re: Declarative pipeline branch condition not working

Try just

branch "master"

maybe? If that doesn't work either, could you try this instead of branch to see what its output is?

expression {
  echo "BRANCH_NAME is ${env.BRANCH_NAME}"
  return env.BRANCH_NAME == "master"
}

Thanks!

onionhead0708@gmail.com (JIRA)

unread,
Nov 29, 2018, 5:30:02 AM11/29/18
to jenkinsc...@googlegroups.com

Another workaround is to use:

when {
  expression {
    return env.GIT_BRANCH == "origin/master"
  }
} 

 

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:41 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Not A Defect
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages