Can I use pip to install a package from a private VSTS repository?











up vote
4
down vote

favorite
2












I would like to install a private package for my python app with pip.



My package is stored in a git repo on Azure DevOps (Visual Studio Team Services).



I see that git is supported by pip, but I cannot determine a workable format for the URL for Azure.



I would like to avoid the Credential Manager. I have tried both git+ssh (with key) and git+https (with Personal Access Token).



Is it possible to do this with Azure/VSTS?



For context, I referenced these resources:



https://www.revsys.com/tidbits/using-private-packages-python/



Is it possible to use pip to install a package from a private github repository?



Here are some of my attempts:



git+https://myUsername:myAccessToken@myCompany.visualstudio.com/myProject/_git/myPackage.git
git+https://<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@<myCompany>.visualstudio.com/<myteam>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+ssh://myCompany@vs-ssh.visualstudio.com:v3/myCompany/<myProject>.git@<ref>









share|improve this question


















  • 1




    Not sure this helps, but could you please try this
    – Jayendran
    Nov 7 at 3:23










  • @jayendran, that is exactly the problem! My scenario is outside of the build pipeline, but that led me to the correct format. Formulate that into an answer and I'll mark it correct. Thank you!
    – Scott Coldwell
    Nov 7 at 20:18















up vote
4
down vote

favorite
2












I would like to install a private package for my python app with pip.



My package is stored in a git repo on Azure DevOps (Visual Studio Team Services).



I see that git is supported by pip, but I cannot determine a workable format for the URL for Azure.



I would like to avoid the Credential Manager. I have tried both git+ssh (with key) and git+https (with Personal Access Token).



Is it possible to do this with Azure/VSTS?



For context, I referenced these resources:



https://www.revsys.com/tidbits/using-private-packages-python/



Is it possible to use pip to install a package from a private github repository?



Here are some of my attempts:



git+https://myUsername:myAccessToken@myCompany.visualstudio.com/myProject/_git/myPackage.git
git+https://<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@<myCompany>.visualstudio.com/<myteam>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+ssh://myCompany@vs-ssh.visualstudio.com:v3/myCompany/<myProject>.git@<ref>









share|improve this question


















  • 1




    Not sure this helps, but could you please try this
    – Jayendran
    Nov 7 at 3:23










  • @jayendran, that is exactly the problem! My scenario is outside of the build pipeline, but that led me to the correct format. Formulate that into an answer and I'll mark it correct. Thank you!
    – Scott Coldwell
    Nov 7 at 20:18













up vote
4
down vote

favorite
2









up vote
4
down vote

favorite
2






2





I would like to install a private package for my python app with pip.



My package is stored in a git repo on Azure DevOps (Visual Studio Team Services).



I see that git is supported by pip, but I cannot determine a workable format for the URL for Azure.



I would like to avoid the Credential Manager. I have tried both git+ssh (with key) and git+https (with Personal Access Token).



Is it possible to do this with Azure/VSTS?



For context, I referenced these resources:



https://www.revsys.com/tidbits/using-private-packages-python/



Is it possible to use pip to install a package from a private github repository?



Here are some of my attempts:



git+https://myUsername:myAccessToken@myCompany.visualstudio.com/myProject/_git/myPackage.git
git+https://<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@<myCompany>.visualstudio.com/<myteam>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+ssh://myCompany@vs-ssh.visualstudio.com:v3/myCompany/<myProject>.git@<ref>









share|improve this question













I would like to install a private package for my python app with pip.



My package is stored in a git repo on Azure DevOps (Visual Studio Team Services).



I see that git is supported by pip, but I cannot determine a workable format for the URL for Azure.



I would like to avoid the Credential Manager. I have tried both git+ssh (with key) and git+https (with Personal Access Token).



Is it possible to do this with Azure/VSTS?



For context, I referenced these resources:



https://www.revsys.com/tidbits/using-private-packages-python/



Is it possible to use pip to install a package from a private github repository?



Here are some of my attempts:



git+https://myUsername:myAccessToken@myCompany.visualstudio.com/myProject/_git/myPackage.git
git+https://<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@<myCompany>.visualstudio.com/<myteam>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+ssh://myCompany@vs-ssh.visualstudio.com:v3/myCompany/<myProject>.git@<ref>






git pip azure-devops






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 6 at 22:56









Scott Coldwell

764412




764412








  • 1




    Not sure this helps, but could you please try this
    – Jayendran
    Nov 7 at 3:23










  • @jayendran, that is exactly the problem! My scenario is outside of the build pipeline, but that led me to the correct format. Formulate that into an answer and I'll mark it correct. Thank you!
    – Scott Coldwell
    Nov 7 at 20:18














  • 1




    Not sure this helps, but could you please try this
    – Jayendran
    Nov 7 at 3:23










  • @jayendran, that is exactly the problem! My scenario is outside of the build pipeline, but that led me to the correct format. Formulate that into an answer and I'll mark it correct. Thank you!
    – Scott Coldwell
    Nov 7 at 20:18








1




1




Not sure this helps, but could you please try this
– Jayendran
Nov 7 at 3:23




Not sure this helps, but could you please try this
– Jayendran
Nov 7 at 3:23












@jayendran, that is exactly the problem! My scenario is outside of the build pipeline, but that led me to the correct format. Formulate that into an answer and I'll mark it correct. Thank you!
– Scott Coldwell
Nov 7 at 20:18




@jayendran, that is exactly the problem! My scenario is outside of the build pipeline, but that led me to the correct format. Formulate that into an answer and I'll mark it correct. Thank you!
– Scott Coldwell
Nov 7 at 20:18












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










It is possible, please have a look it to this existing Request



As per that, you need to follow the below steps,




  • Check the Allow script to access the OAuth token in the Agent job
    phase

  • Include the Task: command Line

  • Add $(System.AccessToken) between repo clone URL


This above is the System variable, you can find the full details here



You can also use the Rest API like below for getting the access token



$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build-release/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
Write-Host "URL: $url"
$pipeline = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 1000)"





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53181349%2fcan-i-use-pip-to-install-a-package-from-a-private-vsts-repository%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    It is possible, please have a look it to this existing Request



    As per that, you need to follow the below steps,




    • Check the Allow script to access the OAuth token in the Agent job
      phase

    • Include the Task: command Line

    • Add $(System.AccessToken) between repo clone URL


    This above is the System variable, you can find the full details here



    You can also use the Rest API like below for getting the access token



    $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build-release/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
    Write-Host "URL: $url"
    $pipeline = Invoke-RestMethod -Uri $url -Headers @{
    Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
    }
    Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 1000)"





    share|improve this answer

























      up vote
      2
      down vote



      accepted










      It is possible, please have a look it to this existing Request



      As per that, you need to follow the below steps,




      • Check the Allow script to access the OAuth token in the Agent job
        phase

      • Include the Task: command Line

      • Add $(System.AccessToken) between repo clone URL


      This above is the System variable, you can find the full details here



      You can also use the Rest API like below for getting the access token



      $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build-release/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
      Write-Host "URL: $url"
      $pipeline = Invoke-RestMethod -Uri $url -Headers @{
      Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
      }
      Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 1000)"





      share|improve this answer























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        It is possible, please have a look it to this existing Request



        As per that, you need to follow the below steps,




        • Check the Allow script to access the OAuth token in the Agent job
          phase

        • Include the Task: command Line

        • Add $(System.AccessToken) between repo clone URL


        This above is the System variable, you can find the full details here



        You can also use the Rest API like below for getting the access token



        $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build-release/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
        Write-Host "URL: $url"
        $pipeline = Invoke-RestMethod -Uri $url -Headers @{
        Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
        }
        Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 1000)"





        share|improve this answer












        It is possible, please have a look it to this existing Request



        As per that, you need to follow the below steps,




        • Check the Allow script to access the OAuth token in the Agent job
          phase

        • Include the Task: command Line

        • Add $(System.AccessToken) between repo clone URL


        This above is the System variable, you can find the full details here



        You can also use the Rest API like below for getting the access token



        $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build-release/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
        Write-Host "URL: $url"
        $pipeline = Invoke-RestMethod -Uri $url -Headers @{
        Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
        }
        Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 1000)"






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 8 at 2:08









        Jayendran

        2,94631334




        2,94631334






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53181349%2fcan-i-use-pip-to-install-a-package-from-a-private-vsts-repository%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Hercules Kyvelos

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud