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 {
  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 = '', String image =  '', Closure body) {
    .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 "*"'
        sh "git config --global '${authorName}'"
        sh "git config --global '${authorEmail}'"


Using jenkins pipeline with any git plugin may require many different 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.