0
votes

We have on on premise azure devops server and I'm converting a bunch of Mercurial repositories to it. It's too many to do manually so scripting it with the az devops extensions.

Creating the repos works great.

function createproject
{
    az devops project create --name=$1

    pushd $2
    
    rm -rf .hg
    rm -f .hgignore
    
    git init
    
    git remote add origin https://server.com/projects/$1/_git/$1
    git add .
    git commit -m "initial commit"
    git push origin master

    popd  
}

    for dir in ./*/ ;
    do
        echo ${dir:2:-1}
            
        createproject ${dir:2:-1} $dir
    done 

But the project gets some default team and I need to add individual users to the projects.

az devops project show --project=Project

  "defaultTeam": {
    "id": "77f27a5c-1a1f-49cc-a6be-f14474e88929",
    "name": "ProjectTeam",
    "url": "https://url/fipsg_projects/_apis/projects/8d96eb91-0db4-4a10-8ce2-6066c13487c3/teams/77

How to to add individual users to the repos/team?

for dir in ./*/ ;
do
    echo ${dir:2:-1}
        
    adduser ?????? ${dir:2:-1} $dir
done 
1

1 Answers

1
votes

You can use az devops security group membership command to add users to the project team. See here.

az devops security group membership add --group-id "group descriptor" --member-id "user descriptor"

1, The default project team is actually a group with the name YourProject Team of the Project. You can get its group descriptor using below commands.

az devops security group list --project YourProject

enter image description here

2, To get the user descriptor. You can use below command:

az devops user show --user [email protected]

enter image description here

  1. Then use az devops security group membership add to add user to the group.

az devops security group membership add --group-id "group descriptor" --member-id "user descriptor"

The changes may take a while to sync with azure devops server.