Uploaded image for project: 'Gradle Artifactory Plug-in'
  1. Gradle Artifactory Plug-in
  2. GAP-259

Cannot specify username and password with conditional *hasProperty(...)* statement

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 4.4.0
    • Fix Version/s: None
    • Environment:

      Running on a Mac in an Android library project.

      Description

      I have my Artifactory username and password declared in the build.gradle file in my HOME folder.

      If I declare the artifactory block in my build.gradle file as follows:

      artifactory {
          contextUrl = getProperty('artifactory_url')
          publish {
              repository {
                  repoKey = getProperty('artifactory_repoKey')
                  username = getProperty('artifactory_username')
                  password = getProperty('artifactory_password')
              }
              defaults {
                  publications('SomePublication')
                  publishArtifacts = true
                  properties = ['qa.level': 'basic', 'dev.team': 'core']
                  publishPom = true
              }
          }
      }
      

      This works and I am able to publish to Artifactory with the artfiactoryPublish Gradle task. I'd like to make the artifactory_username and artifactory_password Gradle properties optional however so all developers do not need to have the properties declared on their machines for the project to build. To this effect I'd like to specify the username and password in the artifactory block as follows:

      username = hasProperty('artifactory_username') ? getProperty('artifactory_username') : ''
      password = hasProperty('artifactory_password') ? getProperty('artifactory_password') : ''
      

      Unfortunately when I now try publish with the artfiactoryPublish Gradle task I get a 401 unauthorized error as follows:

      > java.io.IOException: Failed to deploy file: HTTP response code: 401. HTTP response message: Unauthorized

      The following also fails with a similar 401 unauthorized error message:

      username = findProperty('artifactory_username')
      password = findProperty('artifactory_password')
      

      Any ideas on why using hasProperty(...) and findProperty(...) do not work?

        Attachments

          Activity

            People

            Assignee:
            eyalbe Eyal Ben David
            Reporter:
            adil-hussain-84 Adil Hussain (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: