I use this azure pipeline and it work fine for me:
trigger: noneschedules: - cron: "0/10 * * * *" displayName: Nuget JFrog to Azure DevOps Artifacts branches: include: - main always: truejobs: - job: SyncArtifactory pool: name: 'Ubuntu-latest' steps: - task: JfrogCliV2@1 inputs: jfrogPlatformConnection: 'JFrog Artifactory' command: 'jf rt dl randomPath/Random.Nuget.Package.1.0.1.nupkg' - task: NuGetCommand@2 inputs: command: 'push' packagesToPush: '$(System.DefaultWorkingDirectory)/Random.Nuget.Package.1.0.1.nupkg' nuGetFeedType: 'internal' publishVstsFeed: '<Azure_Devops_Feed>'
Now i want modify this pipeline for deploy nugets dynamically. I mean something like this:
trigger: noneschedules: - cron: "0/10 * * * *" displayName: Nuget JFrog to Azure DevOps Artifacts branches: include: - main always: trueparameters: - name: packages type: object default: - name: "Random.Nuget.Package.1" version: "latest" - name: "Random.Nuget.Package.2" version: "latest" - name: "Random.Nuget.Package.3" version: "latest"jobs: - job: SyncArtifactory pool: name: 'Ubuntu-latest' steps: - ${{ each package in parameters.packages }}: - task: JfrogCliV2@1 inputs: jfrogPlatformConnection: 'JFrog Artifactory' command: 'jf rt s "randomPath/Random.Nuget.Package/*" --limit 1 --sort-by created --sort-order desc --format json' displayName: 'Search for Latest Package ${{ package.name }}' name: ${{ format('SearchPackage_{0}', replace(package.name, '.', '_')) }} - script: | latest_version=$(jq -r '.[].name' $(System.DefaultWorkingDirectory)/${{ format('SearchPackage_{0}', replace(package.name, '.', '_')) }}.json) echo "##vso[task.setvariable variable=LATEST_VERSION]$latest_version" displayName: 'Set Latest Version Variable' - task: JfrogCliV2@1 inputs: jfrogPlatformConnection: 'JFrog Artifactory' command: | jf rt dl randomPath/${{ package.name }}/${{ variables.LATEST_VERSION }}.nupkg displayName: 'Download Latest Package ${{ package.name }}' - task: NuGetCommand@2 inputs: command: 'push' packagesToPush: '$(System.DefaultWorkingDirectory)/${{ package.name }}.${{ variables.LATEST_VERSION }}.nupkg' nuGetFeedType: 'internal' publishVstsFeed: '<Azure_Devops_Feed>' displayName: 'Push Package to Azure Artifacts'
If i use my modified script i have this error:
`Found tool in cache: jf 2.56.1 x64Running jfrog-cli from /opt/azdevops/agent-02/_work/_tool/jf/2.56.1/x64/jfJFrog CLI version: 2.56.1Executing JFrog CLI Command:/opt/azdevops/agent-02/_work/_tool/jf/2.56.1/x64/jf c add "test-nuget_20240523.26_jfrog_cli_cmd_1716472614658" --url="https://<my_artifactory>/" --interactive=false --user='**' --basic-auth-only --password-stdinExecuting JFrog CLI Command:/opt/azdevops/agent-02/_work/_tool/jf/2.56.1/x64/jf c use "test-nuget_20240523.26_jfrog_cli_cmd_1716472614658"13:57:06 [Info] Using server ID 'test-nuget_20240523.26_jfrog_cli_cmd_1716472614658' (https://<my_artifactory>/)Executing JFrog CLI Command:/opt/azdevops/agent-02/_work/_tool/jf/2.56.1/x64/jf rt s "randomPath/Random.Nuget.Package/" --limit 1 --sort-by created --sort-order desc --format json13:57:06 [Error] Wrong number of arguments (3). You can read the documentation at https://jfrog.com/help/r/jfrog-cli
Name:jf rt search - Search files in Artifactory.
--server-id [Optional] Server ID configured using the config command.--sort-by [Optional] List of semicolon-separated(;) fields to sort by. The fields must be part of the 'items' AQL domain. For more information, see https://jfrog.com/help/r/jfrog-artifactory-documentation/artifactory-query-language--sort-order [Default: asc] The order by which fields in the 'sort-by' option should be sorted. Accepts 'asc' or 'desc'.--spec [Optional] Path to a File Spec.--spec-vars [Optional] List of semicolon-separated(;) variables in the form of "key1=value1;key2=value2;..." (wrapped by quotes) to be replaced in the File Spec. In the File Spec, the variables should be used as follows: ${key1}.--ssh-key-path [Optional] SSH key file path.--ssh-passphrase [Optional] SSH key passphrase.--transitive [Default: false] Set to true to look for artifacts also in remote repositories. The search will run on the first five remote repositories within the virtual repository. Available on Artifactory version 7.17.0 or higher.--url [Optional] JFrog Artifactory URL.--user [Optional] JFrog username.
Environment Variables:JFROG_CLI_FAIL_NO_OP[Default: false]Set to true if you'd like the command to return exit code 2 in case of no files are affected.Support by the following commands: copy, delete, delete-props, set-props, download, move, search and upload
##[error]Error: Command failed: /opt/azdevops/agent-02/_work/_tool/jf/2.56.1/x64/jf rt s "randomPath/Random.Nuget.Package/*" --limit 1 --sort-by created --sort-order desc --format jsonExecuting JFrog CLI Command:/opt/azdevops/agent-02/_work/_tool/jf/2.56.1/x64/jf c remove "test-nuget_20240523.26_jfrog_cli_cmd_1716472614658" --quiet`
So i want fisrt step check i have latest version in JFrog or not, if i have i will start download latest version .nupkg and push it to Azure Devops Artifacts.
Can you help me resolve it please?