JobDSL: Problem defining copyArtifacts action inside promotion with configure block

42 views
Skip to first unread message

Dirk Heinrichs

unread,
Feb 12, 2018, 8:12:23 AM2/12/18
to jenkins...@googlegroups.com

Hi,

 

while trying to setup a copyArtifacts action inside a promotion, using the following definition

 

 

            actions {

              copyArtifacts('${PROMOTED_ JOB_NAME}') {

                buildSelector {

                  specific { buildNumber('${PROMOTED_NUMBER}') }

                }

                flatten(false)

                includePatterns('moveBinaries.properties')

                optional(false)

                targetDirectory('${PROMOTED_NUMBER}')

              }

            }

 

I got an error when running the seed job:

 

ERROR: Found multiple extensions which provide method specific with arguments [JobDSL.TheJob$_build_closure1$_closure4$_closure10$_closure11$_closure13$_closure14$_closure17$_closure18@37fe6593]: [[com.tikal.jenkins.plugins.multijob.MultiJobBuildSelector, hudson.plugins.copyartifact.SpecificBuildSelector]]

 

So the “specific” build selector produces a method name clash with MultiJobBuildSelector. I therefor tried to add the build selector by using a configure block as follows:

 

 

            actions {

              copyArtifacts('${PROMOTED_ JOB_NAME}') {

                configure { node ->

                  node / 'selector' << 'hudson.plugins.copyartifact.SpecificBuildSelector' {

                    buildNumber('${PROMOTED_NUMBER}')

                  }

                }

                flatten(false)

                includePatterns('moveBinaries.properties')

                optional(false)

                targetDirectory('${PROMOTED_NUMBER}')

              }

            }

 

This time the seed job didn’t fail, but the generated job had an empty StatusBuildSelector defined, like so:

 

<selector class="hudson.plugins.copyartifact.StatusBuildSelector"/>

 

Any idea what could be wrong here and how I can get the specific build selector into the job config?

 

Thanks…

 

                Dirk

--

Dirk Heinrichs

Senior Systems Engineer, Delivery Pipeline

OpenText ™ Discovery | Recommind

Email: dhei...@opentext.com

Website: www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

 

Victor Martinez

unread,
Feb 12, 2018, 8:36:13 AM2/12/18
to Jenkins Users
Hi there,

    I don't see any configure block in the copyartifacts dsl definition (https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.step.StepContext.copyArtifacts) . You might need to use the global configure block to be able to use it accordingly.

But you can simplify the DSL if you use the 'generated DSL' itself, <YOUR_JENKINS_URL>/plugin/job-dsl/api-viewer/index.html#method/javaposse.jobdsl.dsl.helpers.step.StepContext.copyArtifacts 

so something like the below snippet should work

freeStyleJob('test-job') {
  properties{
    promotions {
      promotion {
              ...
        actions {
          copyArtifacts('upstream') {
            ...
            buildSelector {
                buildNumber('${PROMOTED_NUMBER}')
            }
          }
        }
      }
    }
  }
}


Cheers

Victor Martinez

unread,
Feb 12, 2018, 8:39:33 AM2/12/18
to Jenkins Users
Besides of that,

  the `specific` block is not part of the DSL definition of `copyArtifacts` as far as I see, but you could use any of the below DSLs:
- <YOUR_JENKINS_URL>/plugin/job-dsl/api-viewer/index.html#path/javaposse.jobdsl.dsl.helpers.step.StepContext.copyArtifacts-buildSelector-specificBuildSelector

Cheers

Dirk Heinrichs

unread,
Feb 12, 2018, 9:00:09 AM2/12/18
to jenkins...@googlegroups.com

Hi,

 

thanks for quick reply.

 

>  the `specific` block is not part of the DSL definition of `copyArtifacts` as far as I see, but you could use any of the below DSLs:

> - <YOUR_JENKINS_URL>/plugin/job-dsl/api-viewer/index.html#path/javaposse.jobdsl.dsl.helpers.step.StepContext.copyArtifacts-buildSelector-specificBuildSelector

 

Well, I use the JobDSL API documentation as provided by our Jenkins server itself, and that one looks a bit different (comments removed):

 

copyArtifacts(String jobName) {

    buildSelector {

        buildNumber(int buildNumber)

        buildNumber(String buildNumber)

        …

        specific {

            buildNumber(String value)

        }

        …

    }

    …

}

 

However, I didn’t spot the first two buildNumber() methods at the top right away, but only the “specific” block. Using it as you suggested indeed fixed the problem.

 

Thanks a lot.

 

Bye…

 

                Dirk

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e19d957a-6fe7-42ec-8523-7e747445efae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages