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

Seed Job - Picks up incorrect Boolean Operator Classes

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • job-dsl-plugin
    • None
    • unix

      Job DSL boolean operators in singleConditionalBuilder do not work. they appear to pick up incorrect classes

      ERROR: (seed_job.groovy, line 298) No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.and() is applicable for argument types: (seed_job$_freestyle_closure6$_closure59$_closure69$_closure71$_closure74, seed_job$_freestyle_closure6$_closure59$_closure69$_closure71$_closure75) values: [seed_job$_freestyle_closure6$_closure59$_closure69$_closure71$_closure74@78db9567, ...]

      `

      singleConditionalBuilder {
      condition {
      and {
      status('ABORTED', 'FAILURE')
      } {
      not {
      fileExists('script.sh', BaseDir.WORKSPACE)
      }
      }
      }
      runner

      { fail() }

      buildStep {
      shell

      { command(job.command) }

      }
      }

      `

       

       

       

       

          [JENKINS-57433] Seed Job - Picks up incorrect Boolean Operator Classes

          You can not arbitrarily mix built-in and dynamic DSL. Use the API viewer to lookup the syntax.

          job('example-1') {
            steps {
              singleConditionalBuilder {
                condition {
                  and {
                    conditions {
                      conditionContainer {
                        condition {
                          statusCondition {
                            bestResult('FAILURE')
                            worstResult('ABORTED')
                          }
                        }
                      } 
                      conditionContainer {
                        condition {
                          not {
                            condition {
                              fileExistsCondition {
                                baseDir {
                                  workspace()
                                }
                                file('script.sh')
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
                runner {
                  fail()
                }
                buildStep {
                  shell {
                    command('echo Hello World')
                  }
                }
              }
            }
          }job('example-2') {
            steps {
              conditionalSteps {
                condition {
                  and {
                    status('ABORTED', 'FAILURE')
                  } {
                    not {
                      fileExists('script.sh', BaseDir.WORKSPACE)
                    }
                  }
                }
                runner('Fail')
                steps {
                  shell {
                    command('echo Hello World')
                  }
                }
              }
            }
          } 

          Daniel Spilker added a comment - You can not arbitrarily mix built-in and dynamic DSL. Use the API viewer to lookup the syntax. job( 'example-1' ) { steps { singleConditionalBuilder { condition { and { conditions { conditionContainer { condition { statusCondition { bestResult( 'FAILURE' ) worstResult( 'ABORTED' ) } } } conditionContainer { condition { not { condition { fileExistsCondition { baseDir { workspace() } file( 'script.sh' ) } } } } } } } } runner { fail() } buildStep { shell { command( 'echo Hello World' ) } } } } }job( 'example-2' ) { steps { conditionalSteps { condition { and { status( 'ABORTED' , 'FAILURE' ) } { not { fileExists( 'script.sh' , BaseDir.WORKSPACE) } } } runner( 'Fail' ) steps { shell { command( 'echo Hello World' ) } } } } }

            daspilker Daniel Spilker
            richajam James Richardson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: