Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37396

java.io.NotSerializableException: groovy.sql.GroovyRowResult

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Blocker Blocker
    • pipeline
    • None
    • Centos 7 (3.10.0-327.22.2.el7.x86_64)
      openjdk version "1.8.0_101"
      OpenJDK Runtime Environment (build 1.8.0_101-b13)
      OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)
      Jenkins 2.17
      Job DSL plugin 1.48

      When querying a MySQL database to perform functions on the resulting GroovyRowResults, I receive a NotSerializableException when attempting to use a string value from a GroovyRowResult in a "sh" call.

      In my worflow library:

      def mergeEmtTag(tag){
          stage 'Connect to database'
          def db = [url:'jdbc:mysql://localhost:3306/jenkins', user:'jenkins_user', password:'xxxxxxxxxx', driver:'com.mysql.jdbc.Driver']
          def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
      
          stage 'Retrieve all EMTs'
          def rows = sql.rows("SELECT * FROM emts")
          sql.close()
      
          for ( i in rows ) {
      
              sh """
                  if [ -d "${i.slug}" ]; then
                      mkdir "${i.slug}"
                  fi
              """
              dir("${slug}"){
                  sh """
                      git clone "git@bitbucket.org:xxxxxxxx/${row.slug}.git" .
                      cd $slug
                      git remote add upstream git@bitbucket.org:xxxxxxx/emt-master.git
                      git checkout origin/master
                      git fetch --tags upstream
      
                      git merge "${tag}"
      
                      if [ \$? -ne 0 ]; then
                          exit -1
                      fi
      
                      git branch --set-upstream-to=origin/master master
                      git push -u origin master
                   """
               }
          }
      }
      

      Any recommendations on how to accomplish this?

            jglick Jesse Glick
            onlymoreso Joe Roberts
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: