Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45306

Sharing of declarative pipeline between similar projects

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      There are multiple projects with similar pipelines.

      I can reuse declarative pipeline right now by importing library with pipeline defined:
      Jenkinsfile:

      @Library('github.com/my/libs@master') _
      
      common_jenkinsfile {
        // project parameters
      }
      

      github.com/my/libs/common_jenkinsfile.groovy:

      def call(body) {
          def config = [:]
          body.resolveStrategy = Closure.DELEGATE_FIRST
          body.delegate = config
          body()
      
          pipeline {
              agent any
              stages {
                  stage('This one should be skipped') {
                      when {
                          expression { false }
                      }
                      steps {
                          echo "this should be skipped, but it does not ("
                      }
                  }
              }
          }
      }
      

      The problems are:

      • This is not officially supported, so can break with any next Jenkins release
      • 'when' does not work in this case, so stages are never skipped

        Attachments

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                Unassigned
                Reporter:
                vorobievalex Alexander Vorobiev
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: