Skip to content

Create a new release with Jenkins Pipelines

For this we are using the modern approach of declarative pipelines.

You must also ensure your jenkins instance supports docker. Most modern jenkins systems do have support for it, they have embraced it.

pipeline {
  agent {
    any
  }
  environment {
    CI = 'true'
  }
  stages {
    stage('Bump version') {
      when {
        beforeAgent true
        expression { env.BRANCH_IS_PRIMARY }
        not {
          changelog '^bump:.+'
        }
      }
      steps {
        script {
          useCz {
            sh "cz bump --changelog"
          }
         // Here push back to your repository the new commit and tag
        }
      }
    }
  }
}

def useCz(String authorName = 'Jenkins CI Server', String authorEmail = 'your-jenkins@email.com', String image =  'registry.hub.docker.com/commitizen/commitizen:latest', Closure body) {
    docker
    .image(image)
    .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}' -entrypoint='/bin/sh'") {
        sh 'git config --global --add safe.directory "*"'
        sh "git config --global user.email '${authorName}'"
        sh "git config --global user.name '${authorEmail}'"
        body()
    }
}

Warning

Using jenkins pipeline with any git plugin may require many configurations, you'll have to tinker with it until your pipelines properly detects git events. Check your webhook in your git repository and check the "behaviors" and "build strategies" in your pipeline settings.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy