# Sharing steps between declarative pipelines

**URL:** <https://community.jenkins.io/t/sharing-steps-between-declarative-pipelines/15616>\
**Category:** Ask a question\
**Created:** [May 31, 2024, 8:26pm UTC](https://community.jenkins.io/t/sharing-steps-between-declarative-pipelines/15616 "2024-05-31T20:26:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JBiason](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@JBiason](https://community.jenkins.io/u/JBiason)\
**Post date:** [May 31, 2024, 8:26pm UTC](https://community.jenkins.io/t/sharing-steps-between-declarative-pipelines/15616/1 "2024-05-31T20:26:17Z")

</div>

Hey all,

I have a declarative pipeline on a multibranch pipeline in Jenkins 2.440.3. This pipeline is responsible for checkout some related repositories, compile the source code and then run an external testing tool, reporting the results to our Teams installation.

Now I need to create something similar, up to the “compile” part, but doing something different (also, not a multibranch pipeline, and not automatically triggered by changes in the source), and I want to have the similar steps in a shared… thing (library?), that doesn’t need to be compiled or installed.

Basically, I’d like to have

Jenkins.common.

```auto
stage('outside docker') {
    stages {
        stage('Inside machine stage 1') {
            ...
        }

        stage('Inside machine stage 2') {
            ...
        }
    }
}

stage('Inside docker') {
    agent {
        ...
    }

    stages {
        stage('Clone related repo') {
            ...
        }

        stage('Set up compilation') {
            ...
        }

        stage('Build') {
            ...
        }
    }
}

```

And then have two pipelines with something like:

Jenkins.build

```auto
include 'Jenkins.common'

stage('Continuing from common...') {
    stages {
        stage('Tests') {
            ...
        }
    }
}

```

Jenkins.update:

```auto
include 'Jenkins.common'

stage('Continuing from common...') {
    stages {
        stage('Update reference values') {
            ...
        }
    }
}

```

The references I found on the internet said that something like this can be done in scripted pipelines. Is there a way to do something like this with Declarative pipelines?
