[JIRA] (JENKINS-58164) how to use when branch keyword

8 views
Skip to first unread message

luckyhk.lee@samsung.com (JIRA)

unread,
Jun 24, 2019, 9:38:02 AM6/24/19
to jenkinsc...@googlegroups.com
Hokwang Lee created an issue
 
Jenkins / Improvement JENKINS-58164
how to use when branch keyword
Issue Type: Improvement Improvement
Assignee: Unassigned
Components: p4-plugin
Created: 2019-06-24 13:37
Priority: Critical Critical
Reporter: Hokwang Lee

Hi,

 

Is there a p4 way for below ?

 

Please refer to https://jenkins.io/doc/tutorials/build-a-multibranch-pipeline-project/

There's expression like

```

stage('a') {

  when

{     branch 'dev'   }

  steps

{ <snip> }

```

 

How can I use for this in p4?

 

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

luckyhk.lee@samsung.com (JIRA)

unread,
Jun 24, 2019, 9:39:02 AM6/24/19
to jenkinsc...@googlegroups.com
Hokwang Lee updated an issue
Change By: Hokwang Lee
Hi,

 

Is there a p4 way for below ?

 

Please refer to [https://jenkins.io/doc/tutorials/build-a-multibranch-pipeline-project/]

There's expression like
{code:java}
```

stage('a') {

  when {

    branch 'dev'

  }

  steps {

<snip>
  }
}
{code}
```

 

How can I use for this in p4?

 

kwirth@perforce.com (JIRA)

unread,
Jun 24, 2019, 11:18:02 AM6/24/19
to jenkinsc...@googlegroups.com
Karl Wirth commented on Improvement JENKINS-58164
 
Re: how to use when branch keyword

Hello Hokwang Lee,

I have just tested and this seems to work with a multibranch pipeline. In the following only the branch 'main' exists:

pipeline {
    agent any
    stages {
        stage('Checkout') {
	    when {
	       branch 'BRANCH_DOES_NOT_EXIST'
	    }
            steps {
                echo 'Don't show this...'
            }
        }
        stage('Build') {
	when {
	       branch 'main'
	    }
            steps {
                echo 'Building...'
            }
        }
        stage('Test') {
            steps {
                echo 'Testing...'
            }
        }
    }
}

The relevant output I get in the console log is:

[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout)
Stage "Checkout" skipped due to when conditional
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Building...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
Testing...
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

Note that the stage 'Checkout' is successfully skipped when I run this against 'main' because it is not 'BRANCH_DOES_NOT_EXIST'.

 

 

kwirth@perforce.com (JIRA)

unread,
Jun 24, 2019, 11:19:02 AM6/24/19
to jenkinsc...@googlegroups.com
Karl Wirth resolved as Fixed
 

Seems to work.

Change By: Karl Wirth
Status: Open Resolved
Resolution: Fixed

kwirth@perforce.com (JIRA)

unread,
Jun 24, 2019, 11:19:02 AM6/24/19
to jenkinsc...@googlegroups.com
Karl Wirth assigned an issue to Karl Wirth
Change By: Karl Wirth
Assignee: Karl Wirth

kwirth@perforce.com (JIRA)

unread,
Jul 1, 2019, 11:36:02 AM7/1/19
to jenkinsc...@googlegroups.com
Karl Wirth assigned an issue to Unassigned
Reply all
Reply to author
Forward
0 new messages