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

Artifactory dsl code is not loading target repository in the configuration

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Artifactory configuration with dsl as follows. Target repository is empty but config.xml has the value 'libs-snaphost-local'. I attached the screenshot with it. This configuration is for .net

      artifactoryGenericConfigurator {
      details {
      artifactoryName('http://<ip>:<port>/artifactory')
      artifactoryUrl('http://<ip>:<port>/artifactory')
      deployReleaseRepository

      { keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) }

      }
      deployPattern('*.zip')
      }

      Above configuration is failing with following error.

      18:10:05 Time Elapsed 00:00:10.80
      18:10:05 For pattern: *.zip 1 artifacts were found
      18:10:06 ERROR: Target repository cannot be empty
      18:10:06 java.lang.IllegalArgumentException: Target repository cannot be empty

        Attachments

          Activity

          praveen0528 Praveen A created issue -
          Hide
          viggo_ahl Viggo Ahl added a comment - - edited

          Got the same problem as Praveen A. Except that I got the following plugin setup:
          Jenkins 2.12
          Artifactory Plugin 2.5.1
          Job DSL 1.48
          Java 1.8
          OS - Ubuntu

          String artifactory_Name = 'ArtifactoryServer'
          String artifactory_Url = 'http://artifactory.host.se/artifactory'

          artifactoryGenericConfigurator {
          details {
          artifactoryName(artifactory_Name)
          artifactoryUrl(artifactory_Url)
          deployReleaseRepository

          { keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true) }

          deploySnapshotRepository

          { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) }
          resolveReleaseRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) }

          resolveSnapshotRepository

          { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) }

          userPluginKey('')
          userPluginParams('')
          }

          Show
          viggo_ahl Viggo Ahl added a comment - - edited Got the same problem as Praveen A. Except that I got the following plugin setup: Jenkins 2.12 Artifactory Plugin 2.5.1 Job DSL 1.48 Java 1.8 OS - Ubuntu String artifactory_Name = 'ArtifactoryServer' String artifactory_Url = 'http://artifactory.host.se/artifactory' artifactoryGenericConfigurator { details { artifactoryName(artifactory_Name) artifactoryUrl(artifactory_Url) deployReleaseRepository { keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true) } deploySnapshotRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) } resolveReleaseRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) } resolveSnapshotRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) } userPluginKey('') userPluginParams('') }
          rtyler R. Tyler Croy made changes -
          Field Original Value New Value
          Workflow JNJira [ 173002 ] JNJira + In-Review [ 184874 ]
          Hide
          praveen0528 Praveen A added a comment -

          Hi Eyal Ben Moshe,

          Any update on this ? It would be very helpful if you provide an alternative way to do this.

          Regards,
          Praveen

          Show
          praveen0528 Praveen A added a comment - Hi Eyal Ben Moshe , Any update on this ? It would be very helpful if you provide an alternative way to do this. Regards, Praveen
          Hide
          eyalbe Eyal Ben Moshe added a comment -

          Hi,
          The job UI has two fields for the repository selection - a text field and a drop down list. You can choose to configure the repository using one of those fields. The other fields (text or drop down list) may be saved with an empty value in the config.xml. There's another indicator in the config.xml to determine which of the fields to use (when dynamicMode is true, the text fields is used).
          Are you saying that when configuring a repository using the UI, the config.xml does not include the repository key as described above? If this is the case, can you provide the steps to reproduce this issue? Thanks!

          Show
          eyalbe Eyal Ben Moshe added a comment - Hi, The job UI has two fields for the repository selection - a text field and a drop down list. You can choose to configure the repository using one of those fields. The other fields (text or drop down list) may be saved with an empty value in the config.xml. There's another indicator in the config.xml to determine which of the fields to use (when dynamicMode is true, the text fields is used). Are you saying that when configuring a repository using the UI, the config.xml does not include the repository key as described above? If this is the case, can you provide the steps to reproduce this issue? Thanks!
          Hide
          praveen0528 Praveen A added a comment -

          Hi Eyal Ben Moshe ,

          You didn't get my point. I am using dsl plugin to write config-as-code. If you look at the dsl code which I have provided in the description,

          { keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) }

          is given but as attached screenshot, the target repo is not getting loaded with auto generated configuration through the code written.

          I am refreshing repositories manually in the configuration and choosing the value currently due to this issue.

          Show
          praveen0528 Praveen A added a comment - Hi Eyal Ben Moshe , You didn't get my point. I am using dsl plugin to write config-as-code. If you look at the dsl code which I have provided in the description, { keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) } is given but as attached screenshot, the target repo is not getting loaded with auto generated configuration through the code written. I am refreshing repositories manually in the configuration and choosing the value currently due to this issue.
          Hide
          priyeshnn priyesh nn added a comment -

          Any updated on this issue

          Show
          priyeshnn priyesh nn added a comment - Any updated on this issue
          Hide
          eyalbe Eyal Ben Moshe added a comment -

          Here's whay this is happening:
          The snippet in this issue includes the following:

          keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false)

          Notice that "dynamicMode" is set to false. It means that build expects "keyFromSelect" to have the repository value, but instead it is empty, That's the reason why the build is failing with "Target repository cannot be empty".
          For the above example, the DSL can be fixed in one of the following ways:
          Change "dynamicMode(false)" to "dynamicMode(true)"
          OR
          Change "keyFromSelect('')" to keyFromSelect('libs-snapshot-local'')

          Please let me know if this helps.

          Show
          eyalbe Eyal Ben Moshe added a comment - Here's whay this is happening: The snippet in this issue includes the following: keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) Notice that "dynamicMode" is set to false. It means that build expects "keyFromSelect" to have the repository value, but instead it is empty, That's the reason why the build is failing with "Target repository cannot be empty". For the above example, the DSL can be fixed in one of the following ways: Change "dynamicMode(false)" to "dynamicMode(true)" OR Change "keyFromSelect('')" to keyFromSelect('libs-snapshot-local'') Please let me know if this helps.
          Hide
          praveen0528 Praveen A added a comment - - edited

          No Eyal Ben Moshe, It didn't help either.

          I actually tried these combinations first time itself but never worked out.

          Please let me know what config-as-code is working for you at your environment.

          Thanks,
          Praveen

          Show
          praveen0528 Praveen A added a comment - - edited No Eyal Ben Moshe , It didn't help either. I actually tried these combinations first time itself but never worked out. Please let me know what config-as-code is working for you at your environment. Thanks, Praveen
          Hide
          akshatmehta Akshat Mehta added a comment - - edited

          HI Eyal Ben Moshe,

           

          I am encountering the same problem while trying to automate the job creation process.

          Target repository field is empty after trying multiple times.

          below is the code I am using.

           

          Any solutions how that value can be populated, or any other way to integrate DSL with artifactory that solves the problem.

          I could not find any help on google and ended up with this same issue discussed here.

          I am using the latest version of DSL plugin .

           

           

           

          configure { project ->
          project / buildWrappers << 'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator' {
          details {

          artifactoryUrl('abc')
          artifactoryName('abc')

          deployReleaseRepository

          {

          keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true)

           

          {color:#ff0000}}

          }
          deployPattern('.zip ')
          matrixParams('')
          deployBuildInfo(true)
          includeEnvVars(true)
          envVarsPatterns {
          includePatterns('')
          excludePatterns('password,secret,key')
          }
          discardOldBuilds(true)
          discardBuildArtifacts(true)

          }

          Show
          akshatmehta Akshat Mehta added a comment - - edited HI Eyal Ben Moshe ,   I am encountering the same problem while trying to automate the job creation process. Target repository field is empty after trying multiple times. below is the code I am using.   Any solutions how that value can be populated, or any other way to integrate DSL with artifactory that solves the problem. I could not find any help on google and ended up with this same issue discussed here. I am using the latest version of DSL plugin .       configure { project -> project / buildWrappers << 'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator' { details { artifactoryUrl('abc') artifactoryName('abc') deployReleaseRepository { keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true)   {color:#ff0000}} } deployPattern('.zip ') matrixParams('') deployBuildInfo(true) includeEnvVars(true) envVarsPatterns { includePatterns('') excludePatterns(' password , secret , key ') } discardOldBuilds(true) discardBuildArtifacts(true) }
          Hide
          akshatmehta Akshat Mehta added a comment -
          Show
          akshatmehta Akshat Mehta added a comment - @praveen priyesh nn Praveen A
          Hide
          akshatmehta Akshat Mehta added a comment -

          Someone pls help if you guys got the solution of this

          Show
          akshatmehta Akshat Mehta added a comment - Someone pls help if you guys got the solution of this
          Hide
          praveen0528 Praveen A added a comment -

          No Akshat Mehta I didn't get the solution. I left it after the last comment from me. Artifactory repositories refresh is being done manually in my environment.

          Show
          praveen0528 Praveen A added a comment - No Akshat Mehta I didn't get the solution. I left it after the last comment from me. Artifactory repositories refresh is being done manually in my environment.
          Hide
          akshatmehta Akshat Mehta added a comment -

          Hi,

          Can someone help me on this.

          Show
          akshatmehta Akshat Mehta added a comment - Hi, Can someone help me on this.
          Hide
          eyalbe Eyal Ben Moshe added a comment - - edited

          The following configurations works for me:

           

          freeStyleJob('seedJobMaven') \{
           wrappers \{
           artifactoryGenericConfigurator \{
           details \{
           artifactoryName('MH-Artifactory')
           artifactoryUrl('https://artifactory.dal.myhrtg.net/artifactory')
           deployReleaseRepository \{
           keyFromText('')
           keyFromSelect('my-repo-local')
           dynamicMode(false)
           }
           deploySnapshotRepository \{
           keyFromText('')
           keyFromSelect('my-repo-local')
           dynamicMode(false)
           }
           resolveReleaseRepository \{
           keyFromText('')
           keyFromSelect('my-repo-virtual')
           dynamicMode(false)
           }
           resolveSnapshotRepository \{
           keyFromText('')
           keyFromSelect('my-repo-virtual')
           dynamicMode(false)
           }
           userPluginKey(null)
           userPluginParams(null)
           }
           resolverDetails(null)
           deployerCredentialsConfig \{
           credentialsId(null)
           username(null)
           password(null)
           overridingCredentials(false)
           }
           resolverCredentialsConfig \{
           credentialsId(null)
           username(null)
           password(null)
           overridingCredentials(false)
           }
           deployBuildInfo(true)
           artifactoryCombinationFilter('')
           envVarsPatterns\{
           includePatterns('*')
           excludePatterns('')
           }
           discardBuildArtifacts(false)
           discardOldBuilds(false)
           customBuildName(null)
           overrideBuildName(false)
           deployPattern('*.tgz')
           resolvePattern('')
           matrixParams(null)
           useSpecs(false)
           uploadSpec \{
           spec(null)
           filePath(null)
           }
           downloadSpec \{
           spec(null)
           filePath(null)
           }
           includeEnvVars(true)
           multiConfProject(false)
           asyncBuildRetention(false)
           }
           }
          }
          
          
          Show
          eyalbe Eyal Ben Moshe added a comment - - edited The following configurations works for me:   freeStyleJob( 'seedJobMaven' ) \{ wrappers \{ artifactoryGenericConfigurator \{ details \{ artifactoryName( 'MH-Artifactory' ) artifactoryUrl( 'https: //artifactory.dal.myhrtg.net/artifactory' ) deployReleaseRepository \{ keyFromText('') keyFromSelect( 'my-repo-local' ) dynamicMode( false ) } deploySnapshotRepository \{ keyFromText('') keyFromSelect( 'my-repo-local' ) dynamicMode( false ) } resolveReleaseRepository \{ keyFromText('') keyFromSelect( 'my-repo-virtual' ) dynamicMode( false ) } resolveSnapshotRepository \{ keyFromText('') keyFromSelect( 'my-repo-virtual' ) dynamicMode( false ) } userPluginKey( null ) userPluginParams( null ) } resolverDetails( null ) deployerCredentialsConfig \{ credentialsId( null ) username( null ) password( null ) overridingCredentials( false ) } resolverCredentialsConfig \{ credentialsId( null ) username( null ) password( null ) overridingCredentials( false ) } deployBuildInfo( true ) artifactoryCombinationFilter('') envVarsPatterns\{ includePatterns( '*' ) excludePatterns('') } discardBuildArtifacts( false ) discardOldBuilds( false ) customBuildName( null ) overrideBuildName( false ) deployPattern( '*.tgz' ) resolvePattern('') matrixParams( null ) useSpecs( false ) uploadSpec \{ spec( null ) filePath( null ) } downloadSpec \{ spec( null ) filePath( null ) } includeEnvVars( true ) multiConfProject( false ) asyncBuildRetention( false ) } } }
          akshatmehta Akshat Mehta made changes -
          Attachment image-2017-10-09-20-00-04-409.png [ 39978 ]
          Hide
          akshatmehta Akshat Mehta added a comment -

          Target repository is still empty after using the above code. 

           

          This part of code is not working

           

          deployReleaseRepository {
          keyFromText('')
          keyFromSelect('my-repo-local')
          dynamicMode(false)
          }

           

          Show
          akshatmehta Akshat Mehta added a comment - Target repository is still empty after using the above code.    This part of code is not working   deployReleaseRepository { keyFromText('') keyFromSelect('my-repo-local') dynamicMode(false) }  
          Hide
          akshatmehta Akshat Mehta added a comment -

          I want this to be present inside target directory space- 'dt-$JOB_NAME/$BUILD_ID'

          for that i am using

          deployReleaseRepository

          { keyFromText('dt-$JOB_NAME/$BUILD_ID') keyFromSelect('') dynamicMode(true) }

          But the field is empty after running dsl script and getting new job.

          Show
          akshatmehta Akshat Mehta added a comment - I want this to be present inside target directory space- 'dt-$JOB_NAME/$BUILD_ID' for that i am using deployReleaseRepository { keyFromText('dt-$JOB_NAME/$BUILD_ID') keyFromSelect('') dynamicMode(true) } But the field is empty after running dsl script and getting new job.
          Hide
          daspilker Daniel Spilker added a comment -

          See this answer on Stack Overflow about configuring the Artifactory plugin with Job DSL: https://stackoverflow.com/a/48486303/1271460

          Show
          daspilker Daniel Spilker added a comment - See this answer on Stack Overflow about configuring the Artifactory plugin with Job DSL: https://stackoverflow.com/a/48486303/1271460
          daspilker Daniel Spilker made changes -
          Resolution Not A Defect [ 7 ]
          Status Open [ 1 ] Resolved [ 5 ]
          daspilker Daniel Spilker made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          daspilker Daniel Spilker made changes -
          Assignee Eyal Ben Moshe [ eyalbe ] Daniel Spilker [ daspilker ]

            People

            Assignee:
            daspilker Daniel Spilker
            Reporter:
            praveen0528 Praveen A
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: