0

I'm trying to upload a file txt or .nupkg from Azure DevOps pipeline with "cURL" task. but the file is not getting uploaded with 1 warning message.

My Configuration - Configuration with cURL task

Current output -

output

Expected result - Upload file on Nexus server.

Please suggest what I am missing!

Darshana Patel
  • 507
  • 1
  • 11
  • 25
  • Hi, how the things going? Could you upload the file with the cUrl api which executed in command line task? Feel free to share us the latest status thus other SO users can help you. – Mengdi Liang Sep 17 '19 at 02:10

1 Answers1

0

As you can see the error message from your log: Multiple request required, This caused by the API this task generated does not correct for Nexus. In fact, in the first line of log, you can see its API this cUrl task generated:

enter image description here

You can test it in your local command, and will see it failed with same error "400 Bad request". This task could not be used to achieve upload files to Nexus. Refer to its source code file :

curlRunner.arg('-T')
        // arrayify the arg so vsts-task-lib does not try to break args at space
        // this is required for any file input that could potentially contain spaces
        curlRunner.arg([uploadFiles]);

        curlRunner.arg(url);

        if (redirectStderr) {
            curlRunner.arg('--stderr');
            curlRunner.arg('-');
        }

        if (options) {
            curlRunner.line(options);
        }

        if (username || password) {
            var userPassCombo = "";
            if (username) {
                userPassCombo += username;
            }

            userPassCombo += ":";

            if (password) {
                userPassCombo += password;
            }

            curlRunner.arg('-u');
            curlRunner.arg(userPassCombo);
        }

This is the uri of API what the task generated. But according to the Nexus official doc, the correct cUrl API should look like:

curl -v -F r={repostory} -F e={extension} -F g={group id} -F a={artifact id} -F v={version} -F p={packaging} -F file={file path} -u {username}:{password} http://localhost:8081/repository/{repostory}/

Compare with this correct Uri, you can see that the task generated and used does not completed. That's why you received the warning message: 400 Bad request - the cUrl API body does not completed, it required more multiple requests.

To upload the file to Nexus, you can use Command line task with cUrl API script to upload the file to Nexus repostory manager.

enter image description here

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • Hey, Thanks for your reply and Sorry for late replying. Yes, you are right as API request was not with the correct format. Now As you said I am trying it with the command line. I am Lil confuse about what should be my "group ID" here? – Darshana Patel Sep 25 '19 at 09:14
  • @DarshanaPatel, it is the group ID which will display in Nexus. You can customize it. – Mengdi Liang Sep 25 '19 at 09:16
  • I have defined Group ID as org.xx.projectname but not working. As command is not showing any error but not even giving output. Logs ---- – Darshana Patel Sep 25 '19 at 11:26
  • Yes. Its giving the response with the code 200. but I am not able to see the uploaded package to the Nexus repository. – Darshana Patel Sep 25 '19 at 11:33
  • @DarshanaPatel, I assume you'd better raise a new ticket about this. – Mengdi Liang Sep 25 '19 at 13:55
  • This issue has already raised by some one with the link - https://stackoverflow.com/questions/33246797/artifact-is-not-uploaded-to-nexus-repository-via-curl-command. – Darshana Patel Sep 26 '19 at 06:23