How to use Logstashsend in a Kubernetes based Declarative Pipeline?

10/10/2019

The logstashsend command looks like working, but I can't see any logs in logstash neither kibana.

Is this the right place to place logstashsend for a Jenkins Kubernetes Declarative Pipeline? (after calling kaniko)

        stage('Build FLS container') {

            steps {

                checkout([$class: 'GitSCM', 
                    branches: [[name: "[REDACTED]"]],
                    extensions: [[$class: 'CleanBeforeCheckout'], 
                    [$class: 'RelativeTargetDirectory', relativeTargetDir: 'fls']], 
                    userRemoteConfigs: [[credentialsId: '[REDACTED]',
                    url: [REDACTED]]])

                container('maven-jdk-12') {                 
                    configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
                        dir('fls') {
                            sh 'mvn -s $MAVEN_SETTINGS package'
                        }
                    }                                   
                }
                container(name: 'kaniko', shell: '/busybox/sh') {
                    dir('fls') {
                        sh '''#!/busybox/sh
                        /kaniko/executor -f `pwd`/Dockerfile -c `pwd` --insecure --skip-tls-verify --cache=true --destination=[REDACTED]/fls:testing
                        '''
                    }
                }
                logstashSend failBuild: true, maxLines: 2000
            }
        }

The Logstash plugin is configured to use "Logstash TCP" and the connection is working (tested from Jenkins master container with curl)

Thanks

-- echedey lorenzo
elk
jenkins
kubernetes
logstash

0 Answers