Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...


Div
idProductTOC

On this page

Table of Contents
maxLevel1
excludeOn this page
typeflat
separator |

Include Page
recipes:_RecipeTemplateTopLogo
recipes:_RecipeTemplateTopLogo

Recipe overview

This recipe provides step-by-step instructions on how to create a Confluence space and assign appropriate permissions using the Confluence Command Line Utility (CLI) add-on. This allows a Confluence Administrator to quickly, consistently and flawlessly create new spaces when requested by your users.

(info) It will take you approximately 5 minutes to complete this recipe.

Recipe level

Table plus
border0
heading0
multiplefalse
enableHeadingAttributesfalse
columnAttributesstyle="border:0;width=5%;",style="border:0;width=65%;",style="border:0;width=30%;max-width=30% !important;"
enableSortingfalse
classingredients_table
enableHighlightingfalse


Basic RecipesImage Added


Ingredients

Table plus
border0
heading0
multiplefalse
enableHeadingAttributesfalse
columnAttributesstyle="border:0;width=5%;",style="border:0;width=65%;",style="border:0;width=30%;max-width=30% !important;"
enableSortingfalse
classingredients_table
enableHighlightingfalse



...

Table plus
border0
heading0
multiplefalse
enableHeadingAttributesfalse
columnAttributesstyle="border:0;width=5%;",style="border:0;width=65%;",style="border:0;width=30%;max-width=30% !important;"
idsteps_table
enableSortingfalse
enableHighlightingfalse


Image Modified

Create Action File

Div
classtime

Estimated Time: 2 min

In this step, you will be creating a text file that contains the CLI actions that will create a Confluence space and set appropriate permissions for it. This file will be invoked and executed in a later step.

  1. Open an editor capable of producing a plain text file, such as Notepad (Windows) or TextEdit (Mac), and then paste in the contents shown to the right.
    1. Line 1 executes the addSpace action to create a new Confluence space using the following parameters:
      • --space defines the space key for the new space.
      • --name defines the name of the new space.
      • --description provides some explanation regarding the purpose or use of the new space.
    2. Line 2 executes the addPermissions action to grant permissions to anonymous users.
    3. Line 3 executes the addPermissions action to grant permissions to members of the confluence-users group.
    4. Line 4 executes the addPermissions action to grant permissions to members of the confluence-administrators group.
    5. Line 5 executes the addPermissions action to grant permissions to a user with the username of "joe" who, in our example, represents the person requesting the new space.

      Note

      You should replace "joe" with a userid that is defined in your JIRA instance.


    6. Lines 2 through 5 use the following parameters for the addPermissions action:

      • --space defines the space key for the new space. It is using a @space@ variable that indicates to use the last referenced space key, which would be the one on Line 1's addSpace action. You could also use the same value used on Line 1 ("newSpaceKey"), but using the variable will result in you making fewer edits when using this file again to create another new space.
      • --userId identifies the username of the user to whom permissions should be granted. This can be a specific person's username (as used on Line 5) or it can also be "anonymous" (as used on Line 2) to grant access to anonymous users. An 'anonymous user' is someone who has not logged in to the Confluence site.
      • --group identifies the group to whom permissions should be granted.
      • --permissions identifies each permission to be granted to the userId or group.

        Expand
        titleView allowable permissions...


        Div
        stylemax-width: 600px;


        PermissionAllows User to...
        COMMENTMake comments in the space.
        CREATEATTACHMENTAdd attachments to pages in the space.
        EDITBLOGAdd blog posts in the space.
        EDITSPACEAdd pages in the space.
        EXPORTPAGE(This option has been deprecated.)
        EXPORTSPACEExport content from the space via the space-level export screens. Note that this permission doesn't affect the exporting of a single page's content. Anyone who has permission to view the page also has permission to export its content.
        REMOVEATTACHMENTDelete attachments from pages in the space.
        REMOVEBLOGDelete blog posts in the space.
        REMOVECOMMENTDelete comments from the space.
        REMOVEMAILDelete individual mail items.
        REMOVEPAGEDelete pages in the space.
        SETPAGEPERMISSIONSApply page-level restrictions.
        SETSPACEPERMISSIONSAdminister this space, including granting permissions to other users. This permission can't be granted to anonymous users (users who aren't logged in).
        VIEWSPACEView content within the space, including pages, blog posts etc.

         

         





  2. Save the file under the name CreateNewWikiSpace_actions.txt in the same folder to which you installed the Confluence CLI client.

Anchor
step1
step1
Example action file:

Code Block
languagetext
themeDJango
titleCreateNewWikiSpace_actions.txt
linenumberstrue
--action addSpace --space "newSpaceKey" --name "newSpaceName" --description "This is the Space Description"
--action addPermissions --space "@space@" --userId "anonymous"                 --permissions "viewspace" 
--action addPermissions --space "@space@" --group  "confluence-users"          --permissions "viewspace,comment,removecomment,editspace,removepage,setpagepermissions,editblog,removeblog,createattachment,removeattachment,exportspace"
--action addPermissions --space "@space@" --group  "confluence-administrators" --permissions "viewspace,comment,removecomment,editspace,removepage,setpagepermissions,editblog,removeblog,createattachment,removeattachment,removemail,exportspace,setspacepermissions"
--action addPermissions --space "@space@" --userId "joe"                       --permissions "viewspace,comment,removecomment,editspace,removepage,setpagepermissions,editblog,removeblog,createattachment,removeattachment,removemail,exportspace,setspacepermissions"
 

 

 






Image Modified

Create Confluence CLI command

Div
classtime

Estimated Time: 2 min

In this step, you will form the command line that will invoke the Confluence CLI to execute the action file you created in the previous step.

The command is shown to the right.

  • confluence indicates to invoke the Confluence CLI client.
  • The run action indicates to run actions from the file identified in the --file parameter.

Anchor
step2
step2
Example command:

Code Block
languagetext
themeDJango
linenumberstrue
confluence --action run --file CreateNewWikiSpace_actions.txt



Image Modified

Execute Confluence CLI command

Div
classtime

 Estimated Time: 1 min 

In your command window, type the command from the previous step and press Enter.

The command will run, showing the result of executing the actions defined in the CreateNewWikiSpace_actions.txt file you created earlier.

Note that Administrator rights to the new space will  automatically be given to the user whose credentials were used when running the Confluence CLI.

If you go into the Space Administration screens to look at the Space Details and Permissions screens, you should see something similar to the screenshots shown to the right.

That's it! With one command, you've created a Confluence space and saved yourself from having to complete many steps to do it!

 


Anchor
step3
step3
Example output:

Code Block
languagetext
themeDJango
linenumberstrue
Run: --action addPermissions --space "newSpaceKey" --userId "anonymous"                 --permissions "viewspace"
[VIEWSPACE] permissions where added to space: 'newSpaceKey' for: 'anonymous'.
Run: --action addPermissions --space "newSpaceKey" --group  "confluence-users"          --permissions "viewspace,comment,removecomment,editspace,removepage,setpagepermissions,editblog,removeblog,createattachment,removeattachment,exportspace"
[VIEWSPACE, COMMENT, REMOVECOMMENT, EDITSPACE, REMOVEPAGE, SETPAGEPERMISSIONS, EDITBLOG, REMOVEBLOG, CREATEATTACHMENT, REMOVEATTACHMENT, EXPORTSPACE] permissions where added to space: 'newSpaceKey' for: 'confluence-users'.
Run: --action addPermissions --space "newSpaceKey" --group  "confluence-administrators" --permissions "viewspace,comment,removecomment,editspace,removepage,setpagepermissions,editblog,removeblog,createattachment,removeattachment,removemail,exportspace,setspacepermissions"
[VIEWSPACE, COMMENT, REMOVECOMMENT, EDITSPACE, REMOVEPAGE, SETPAGEPERMISSIONS, EDITBLOG, REMOVEBLOG, CREATEATTACHMENT, REMOVEATTACHMENT, REMOVEMAIL, EXPORTSPACE, SETSPACEPERMISSIONS] permissions where added to space: 'newSpaceKey' for: 'confluence-administrators'.
Run: --action addPermissions --space "newSpaceKey" --userId "joe"                       --permissions "viewspace,comment,removecomment,editspace,removepage,setpagepermissions,editblog,removeblog,createattachment,removeattachment,removemail,exportspace,setspacepermissions"
[VIEWSPACE, COMMENT, REMOVECOMMENT, EDITSPACE, REMOVEPAGE, SETPAGEPERMISSIONS, EDITBLOG, REMOVEBLOG, CREATEATTACHMENT, REMOVEATTACHMENT, REMOVEMAIL, EXPORTSPACE, SETSPACEPERMISSIONS] permissions where added to space: 'newSpaceKey' for: 'joe'.
Run completed successfully. 5 actions were successful from file: /usr/local/CLI/CreateNewWikiSpace_actions.txt


Expand
titleView newly created space...

Space Details view of newly created Space:

Space Permissions of newly created Space:



Image Modified

Bonus Tip

Div
classtime

 

Status
titleoptional
Estimated Time: 2 min

You may have established one or more sets of "standard permissions" you use in your Confluence site, such as one for a personal space, one for a team space, and another for a public space open to everyone.

If this is the case, you may want to use a modified version of the CreateNewWikiSpace_actions.txt file as shown on the right.

In this modified version, Lines 2 through 5 are replaced with a single line (Line 2) that uses the copyPermissions action so that the new space is created with permissions identical to what is used in another space. The parameters used by this action are:

  • --space which identifies the the space key of a space that has the permissions you want to copy
  • --newSpace which uses the @space@ variable to indicate it is the newly created space to which the other space's permissions should be copied.

Anchor
step4
step4
Modified action file:

Code Block
languagetext
themeDJango
titleCreateNewWikiSpace_actions.txt
linenumberstrue
--action addSpace --space "newSpaceKey" --name "newSpaceName" --description "This is the Space Description"
--action copyPermissions --space "modelspace" --newSpace "@space@"

 




Include Page
recipes:_RecipeTemplateFooter
recipes:_RecipeTemplateFooter