Build
Learn how to build and archive the specified project assets.
APIs can have external dependencies referenced, hence when you build a project it includes all these references provided in the local folder.
Syntax
apic build [options][projects]
projects. Specifies the projects in the local folder you want to build. You can provide multiple projects by providing comma separated project names as input.
The following table lists all available options for the apic build command and their descriptions.
| Options | Description |
|---|---|
| -l, --localDir | Path of the local folder of the specified studio projects. This argument is mandatory. |
| -a, --all | Use --all to include all projects in the given local directory. If you do not want to build all projects in the given local directory, then specify the project name that is required. |
| -n, --names | Specify the api kind in the format
namespace:apiname:version. You can provide multiple asset names as comma separated
entries as input. Studio supports only API assets. |
| -o, --output build_output_path | Provide the name and path where the output zip file should be stored. If you do not specify the path the built project is stored in the directory from where you run the command. |
| -d, --debug | Enables the debug mode. |
| -h, --help | Displays help for the build command. |
1. Building a single project
Syntax
apic build Projectname --localDir local_dir_path
--output build_output_path
Example
apic build Project1 --localDir /Users/user1/Desktop/apistudio_localdir
--output ./builds/project_build.zip
Builds a project project_build.zip from a single project file, Project1, located in the local directory /Users/user1/Desktop/apistudio_localdir and places it in the /builds folder.
Outcome
As the build progresses, it lists the assets added. On successful completion you will see the message Build completed successfully!. In addition it displays the location where the build is placed.
In case of any errors, a deployment failure message with the reason for failure is displayed so you can take the corrective action.
2. Building multiple projects
Syntax
apic build Projectname1,Projectname2
--localDir local_dir_path
--output build_output_path
Example
apic build Project1,Project2 --localDir /Users/user1/Desktop/apistudio_localdir
--output ./builds/project_build.zip
Builds a project project_build.zip from two project files, Project1 and Project2, located in the local directory /Users/user1/Desktop/apistudio_localdir and places it in the /builds folder.
Outcome
As the build progresses, it lists the assets added. On successful completion you will see the message Build completed successfully!. In addition it displays the location where the build is placed.
In case of any errors, a deployment failure message with the reason for failure is displayed so you can take the corrective action.
3. Building all projects in the local directory
Syntax
apic build --all --localDir local_dir_path
--output build_output_path
Example
apic build --all --localDir /Users/user1/Desktop/apistudio_localdir
--output ./builds/project_build.zip
Builds a project project_build.zip by bundling all the projects located in the local directory /Users/user1/Desktop/apistudio_localdir and places it in the /builds folder.
Outcome
As the build progresses, it lists the assets added. On successful completion you will see the message Build completed successfully!. In addition it displays the location where the build is placed.
In case of any errors, a deployment failure message with the reason for failure is displayed so you can take the corrective action.
4. Building an API
Syntax
apic build Projectname1 --names namespace:name:version
--localDir local_dir_path
--output build_output_path
Example
apic build Project1 --names dev:TestPayments:1.0
--localDir /Users/user1/Desktop/apistudio_localdir
--output ./builds/project_build.zip
Builds an API project_build.zip from a single API file specified by its name dev:TestPayments:1.0 located in the local directory /Users/user1/Desktop/apistudio_localdir and places it in the /builds folder.
Outcome
As the build progresses, it lists the assets added. On successful completion you will see the message Build completed successfully!. In addition it displays the location where the build is placed.
In case of any errors, a deployment failure message with the reason for failure is displayed so you can take the corrective action.
5. Building a project without --output
Syntax
apic build Projectname --localDir local_dir_path
Example
apic build Project1 --localDir /Users/user1/Desktop/apistudio_localdir
Builds a project project_build.zip from the project file, Project1, located in the local directory /Users/user1/Desktop/apistudio_localdir. When you do not provide the --output option, APIM CLI builds it with a fixed standard package name, for example, studio-projectname-build.zip and archives it in the same location from where the command is run.
Outcome
As the build progresses, it lists the assets added. On successful completion you will see the message Build completed successfully!. In addition it displays the location where the build is placed.
In case of any errors, a deployment failure message with the reason for failure is displayed so you can take the corrective action.