Eddie
Eddie

Reputation: 1161

How can I kick off a Jenkins job when a new branch is made in gitlab?

I would like to initialize an environment when a new branch is created. I would not like to run a job every time something is committed, only when it is a new branch.

Upvotes: 0

Views: 284

Answers (1)

Eddie
Eddie

Reputation: 1161

The solution I went with is to put logic into my jenkinsfile. Since I'm building the multibranch pipeline from one. I added the logic below...

stage('Deploy') {
   steps {
       script {
          if (env.BUILD_NUMBER == '1') {
            build job: 'new env'
           }else{
            build job: 'deploy'

            }
        }
    }
}

Upvotes: 1

Related Questions