jenkinsci / zulip-plugin

Jenkins plugin for Zulip notifications of build status
https://zulip.com/integrations/doc/jenkins
MIT License
14 stars 22 forks source link

Jenkins Pipepline syntax #7

Closed sschueller closed 5 years ago

sschueller commented 6 years ago

How do I send a message to Zulip in a Jenkins Pipeline (Jenkinsfile) ? For example this is how I would do it with hipchat (https://github.com/jenkinsci/hipchat-plugin):

pipeline {
  agent any
  stages {
    stage('Notify Start') {
      steps {
        hipchatSend(color: 'GRAY', message: "<a href=\"${RUN_DISPLAY_URL}\">Web Job ${env.BUILD_NUMBER} on ${env.BRANCH_NAME} started</a>")
      }
    }
    stage('Automated Tests') {
      steps {
        sh '''# my tests
            '''
        junit 'tests/_output/run'
      }
      post {
        unstable {
          hipchatSend(color: 'RED', notify: true, message: "<a href=\"${RUN_DISPLAY_URL}\">Some tests in web job ${env.BUILD_NUMBER} on ${env.BRANCH_NAME} failed</a>")

        }
        success {
          hipchatSend(color: 'GREEN', notify: false, message: "<a href=\"${RUN_DISPLAY_URL}\">All tests in web job ${env.BUILD_NUMBER} on ${env.BRANCH_NAME} passed</a>")
        }
      }
    }
    stage('Build and Release') {
      when {
        tag 'release_*'
      }
      post {
        failure {
          hipchatSend(color: 'RED', notify: true, message: "<a href=\"${RUN_DISPLAY_URL}\">Build web job ${env.BUILD_NUMBER} on ${env.BRANCH_NAME} failed</a>")

        }

      }
      steps {
        sh "# build"
      } 
    }
    stage('Notify Deployment') {
      when {
        tag 'release_*'
      }
      steps {
        hipchatSend(color: 'GREEN', notify: false, message: "Web Job ${env.BRANCH_NAME} deployed")
      }
    }
  }
}

I also noticed that the Zulip plugin is not showing as an option in the blueocean pipeline editor so maybe this is not supported?

timabbott commented 6 years ago

@sschueller I suspect this is not supported with the current plugin.

timabbott commented 6 years ago

(Let me see about getting someone to work on improving this)

timabbott commented 5 years ago

@sschueller I believe https://github.com/zulip/zulip-jenkins-plugin/pull/8 should have resolved at least parts of this; can you take a look?

timabbott commented 5 years ago

@butchyyyy confirmed that this is fixed via #8, so closing. Thanks again for the report!