<p>It would seem not - in the scripted pipeline, groovy needs to be used - see <a href="https://jenkins.io/doc/book/pipeline/syntax/#flow-control" rel="nofollow noreferrer">the docs</a></p>

<pre class="lang-java prettyprint-override"><code>node {
    stage('Example') {
        if (env.BRANCH_NAME == 'master') {
            echo 'I only execute on the master branch'
        } else {
            echo 'I execute elsewhere'
        }
    }
}

</code></pre>

<p>(taken straight from the docs)</p>

<p>This would be the same as <code>when { branch 'master' }</code></p>

CC BY-SA 4.0
2020-03-31T14:10:22.140Z
Thanks Bruce for sharing this. Well, it is obvious that one can write a code which behaves like when conditions, however both when statement and its conditions are written in java (or maybe even groovy) and, I believe, should be available from a groovy pipeline as well.
Dima
CC BY-SA 4.0
2023-04-16T23:54:10.997Z
@mangolier Those built-in keywords like `stage` and `node` are called steps. You can see all the steps available for a scripted pipeline on this page https://www.jenkins.io/doc/pipeline/steps/ . There is no `when` step.
Levi
CC BY-SA 4.0
2020-03-31T13:52:11.150Z
2020-03-31T13:52:11.150Z
Bruce Becker
<p>Jenkins declarative pipelines offer very convenient <strong>when</strong> directive with conditions like <strong>changeset</strong>.</p>

<p>Is is possible the this changeset and other when conditions in a scripted pipeline?</p>

<jenkins><jenkins-pipeline><jenkinsfile>
Using Jenkins declarative when conditions in scripted pipelines
Dima
# Using Jenkins declarative when conditions in scripted pipelines

(Asked by: username_0 on 2020-03-31)

Jenkins declarative pipelines offer very convenient **when** directive with conditions like **changeset**.

Is is possible the this changeset and other when conditions in a scripted pipeline?

**Tags:** jenkins, jenkins-pipeline, jenkinsfile


---

## 1 answers

### Answer by username_1 on 2020-03-31. Score: 1

It would seem not - in the scripted pipeline, groovy needs to be used - see the docs
node {
    stage('Example') {
        if (env.BRANCH_NAME == 'master') {
            echo 'I only execute on the master branch'
        } else {
            echo 'I execute elsewhere'
        }
    }
}


(taken straight from the docs)
This would be the same as when { branch 'master' }

> **Comments:**
> **username_0**: Thanks Bruce for sharing this. Well, it is obvious that one can write a code which behaves like when conditions, however both when statement and its conditions are written in java (or maybe even groovy) and, I believe, should be available from a groovy pipeline as well.  
> **username_2**: @mangolier Those built-in keywords like `stage` and `node` are called steps. You can see all the steps available for a scripted pipeline on this page https://www.jenkins.io/doc/pipeline/steps/ . There is no `when` step.  

---

