Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Question - Create new project (within a "Group") using New-GitLabProject #204

Open
NealWalters opened this issue Jan 24, 2019 · 3 comments

Comments

@NealWalters
Copy link

NealWalters commented Jan 24, 2019

1. Provide a general summary of the issue in the Title above

How do you specify a "group", is it the -Path or -Namespace or something else?
The GitLab visual interface seems to have an entity known as "groups".
When using the online interface, you create projects under groups.

2. Describe Your Environment

Operating System and PowerShell version:
Win 2012/R2
Powershell
Major Minor Build Revision
5 1 14409 1005

3. Expected Behavior

Run some command to create a project in a group

4.Current Behavior

Test 1
$projName = "MyCompany.MyNewProjectName"
$groupName = "ExistingGroupName"
New-GitLabProject -name $projName -path $groupName

Results
WARNING: All tokens will be sent over HTTP. Recommendation: Use HTTPS.
New-GitLabProject : Cannot bind parameter because parameter 'name' is specified more than once. To provide multiple values to parameters that can accept
multiple values, use the array syntax. For example, "-parameter value1,value2,value3".
At line:15 char:35

  • New-GitLabProject -name $projName -path $groupName
  •                               ~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [New-GitLabProject], ParameterBindingException
    • FullyQualifiedErrorId : ParameterAlreadyBound,New-GitLabProject

Test 2

$projName = "MyCompany.MyNewProjectName"
$groupName = "ExistingGroupName"
New-GitLabProject -name $projName -namespace $groupName

Results:
WARNING: All tokens will be sent over HTTP. Recommendation: Use HTTPS.
QueryGitLabAPI : -
At C:\Program Files (x86)\WindowsPowerShell\Modules\PSGitLab\3.0.1\PSGitLab.psm1:1775 char:9

  •     QueryGitLabAPI -Request $Request -ObjectType 'GitLab.Project'
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,QueryGitLabAPI

5. Possible Solution

Update doc to link the concept of a group to whatever you call it in the API, assuming it does existin the API.

6. Context

See number 1 above

@NealWalters
Copy link
Author

After finding the GroupID, I have tried the following:

$searchGroup = "MyGroupName"
$group = Get-GitLabGroup -Search $searchGroup 
if ($group -eq $null) 
   {
      Write-Host "Group $searchGroup not found" 
   }
else 
   {
      Get-GitLabProject -GroupId $group.id 
      $newProjectname = 'NealTestScriptAddedProject'
      New-GitlabProject -Name $newProjectname  -Namespace "$searchGroup / $newProjectname" -public 
   }

I was guessing one of two things:

  1. That the current group would be used when you add a new project
  2. The group name is part of the namespace. When I listed my existing projects in the group that were created using the GitLab website, I saw the following name/value pair:

name_with_namespace : MyGroupName / MyProjectName

@NealWalters
Copy link
Author

NealWalters commented Jan 25, 2019

Ok, got it! Read this: https://forum.gitlab.com/t/create-a-new-project-in-a-group-using-api/1552/5

Changed one line above:

New-GitlabProject -Name $newProjectname -Namespace "$searchGroup" -public

The namespace is apparently just the group name when adding an item,

I also ran "get-gitlabnamespace" to see the namespaces.
Then I realized that when I retrieved the project that "name with namespace" is not the namespace, but the group name and the namespace.

Next question - how do I set the value of the Wiki for the project? Is it a file that can be uploaded? Or there an API to set it?

Neal

@ngetchell
Copy link
Owner

I don’t have anything around a wiki in the pipeline. You can treat the wiki as a git repository so you should be able to push changes via git.

Close the issue when you’ve seen the reply!

Sent with GitHawk

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants