Usha S.M
Usha S.M

Reputation: 63

How to run multiple pipeline jenkins for multiple branch

I have a scenario where in I have a frontend repository with multiple branches. Here's my repo vs application structure.

I have a single Jenkinsfile like below:

  parameters{
    string(name: 'CUSTOMER_NAME', defaultValue: 'customer_1')
  }

stages {
    stage('Build') {
        steps {
            sh '''
                yarn --mutex network
                /usr/local/bin/grunt fetch_and_deploy:$CUSTOMER_NAME -ac test
                /usr/local/bin/grunt collect_web'''
        }
    }
}

The above Jenkinsfile is same for all customers so I would like to understand what is the best way to have multiple customers build using a same Jenkinsfile and build different pipelines based on the parameter $CUSTOMER_NAME

Upvotes: 4

Views: 2646

Answers (1)

Datz
Datz

Reputation: 3881

I am not sure if I understood your problem. But I guess you could use a shared pipeline library: https://jenkins.io/doc/book/pipeline/shared-libraries/

You can put the build step in the library and call it with CUSTOMER_NAME as parameter.

(Please note: a shared pipeline library must be stored in a separate GIT repository!)

Upvotes: 3

Related Questions