Search code examples
artifactorysalt-project

Use of artifactory.download not working for snapshot version in Salt-stack


I use saltstack to deploy my application on AWS. The formulas fetch the jar from artifactory and run the application as a service.

It works fine for production(release version ex: 1.1.3) but it fails on dev environment with snapshot version (ex: 1.1.4-SNAPSHOT).

My formula :

artifactory.downloaded:
   - artifact:
        artifactory_url: {{ artifactory_url }}
        repository: {{ repository }}
        artifact_id: {{ artifact_id }}
        group_id: {{ group_id }}
        packaging: {{ packaging }}
        classifier: {{ classifier }}
        version: '{{ version }}'
   - target_dir: {{ folder }}

The error: 'NoneType' object is not iterable


Solution

  • I think I figure it out.

    The state artifactory.downloaded use the module artifactory.get_snapshot for snapshot and artifactory.get_release for release.

    The get_snapshot module needs a snapshot_version properties and version properties (I think it's an issue) but you can't pass snapshot_version properties from artifactory.downloaded state.

    So to resolve this issue, I don't longer use artifactory.downloaded state but artifactory.get_snapshot / artifactory.get_release module :

    artifact_download:
     module.run:
        - name: artifactory.get_snapshot
        - artifactory_url: {{ artifactory_url }}
        - repository: {{ repository }}
        - artifact_id: {{artifact_id }}
        - group_id: {{ group_id }}
        - packaging: {{ packaging }}
        - classifier: {{ classifier }}
        - version: '{{ version }}'
        - snapshot_version: '{{ version }}'
        - target_dir: {{ folder }}
    

    ⚠️ - snapshot_version and version properties are both required.