无法使用curl获取gitlap项目ID?

时间:2019-11-04 08:41:41

标签: api curl gitlab

我正在使用如下所示的curl,但是会引发4o4错误。我不熟悉卷曲和时髦。

任何人都可以帮助我完成这项任务

我正在使用如下方式:

def gitlabCommitStatus(String status) {
    // chcking
    checkBranchName();
    def urlCheck = executeCommand('git config --get remote.origin.url');
    println('urlCheck-------' +urlCheck);
    
    projectNameCheck = executeCommand("basename $urlCheck .git");
    println('projectNameCheck------' +projectNameCheck);
    
    def formats = '%2f';
    def projectCurlCheck = "curl -s --header 'PRIVATE-TOKEN: $gitlabToken' $gitlabAPI/essential-studio$formats$projectNameCheck";
    projectCurlCheck = projectCurlCheck.replace("'", '"');
    println('projectCurlCheck-----' +projectCurlCheck);
    
    def projectCheck = executeCommand(projectCurlCheck);
    println('projectCheck----' + projectCheck);
    
    projectIdCheck = new groovy.json.JsonSlurperClassic().parseText(projectCheck).id;
    //end checking
    println('projectIdCheck------' +projectIdCheck);

}

和我的错误:

[EJ2_ej2-web-services_master-L3UJO4BNML65HWRTAQGOREK2LM7VEJ4CBEQD6JC7SOIPDJNVUPEQ] Running batch script
[Pipeline] readFile
[Pipeline] echo
projectNameCheck------ej2-web-services
[Pipeline] echo
projectCurlCheck-----curl -s --header "PRIVATE-TOKEN: ysfsdfoV7K" https://gitlab.syncfusion.com/api/v3/projects/essential-studio%2fej2-web-services
[Pipeline] isUnix
[Pipeline] bat
[EJ2_ej2-web-services_master-L3UJO4BNML65HWRTAQGOREK2LM7VEJ4CBEQD6JC7SOIPDJNVUPEQ] Running batch script
[Pipeline] readFile
[Pipeline] echo
projectCheck----{"message":"404 Project Not Found"}
[Pipeline] echo
projectIdCheck------null

我已经提到了以下问题,但没有任何解决办法

How to access GitLab issues using CURL?

Can't find out base GitLab API base url

0 个答案:

没有答案