Python API package function
You can use the package function to create a build in the artifact repository to upload the content of a local folder that contains the artifacts of an application. It is as an alternative to the wazideploy-package command.
For explanations about all the function parameters, which are indicated between parentheses, see the Parameters section below.
- Description
-
For more information on the wazideploy-package command, see The Wazi Deploy packager command.
Before you call the corresponding Python function, import the following packages:
from wazideploy.service.wd_services import package from wazideploy.exception.exception import WD_Exception
- Returns
-
- rc (
int
):The return code. Its value is 0 if the function succeeded, or 1 if it failed.
- stdout (
str
):The standard output stream for all the messages that are output during the execution of the function.
- stderr (
str
):The standard error stream for all the error messages that are output during the execution of the function.
If no error occurred, the stderr value is None.
If an error occurred, stderr contains the error messages.
- rc (
- Raise
-
Some errors, which do not come from the validation controls of the function, might be raised. These errors constitute exceptions (WD_Exception). An exception returns the following elements, which you need to look into or communicate to the support team:
- rc (
int
):The return code. Its value is always 1 because the function failed.
- stdout (
str
):The standard output stream for all the messages that are output during the execution of the function. These messages are the error messages that come from the validation controls of the function, the error messages of the exceptions, and the other messages.
- stderr (
str
):The standard error stream for the error messages of the exceptions, which are output during the execution of the function.
- message (
str
):The error message of the exception.
- exc (
str
):The alphabetic string of the exception.
- rc (
- Parameters
-
- manifest_name (
str
):The name of the application in the manifest file.
- manifest_version (
str
) - Required:The version of the application in the manifest file.
- manifest_description (
str
):The description of the application in the manifest file.
It is replaced by the manifest name if it is not specified.
- manifest (
str
) - Required:The new manifest file to generate.Enter the local path to the manifest file.
- manifest_extension (
str
):The Python module extension path to amend the generated manifest file. - manifest_extension_options (
str
):The options transmitted to the Python module manifest extension. - build_name (
str
):The Artifactory build name.It is required for Artifactory when the
--uploadType
is set tofolder
. If it is not indicated when--uploadType
is set toarchive
, an Artifactory Build Info is not created.It is forbidden for Nexus.
- build_number (
str
):The Artifactory build number (only for Artifactory. Forbidden for Nexus).If you do not specify it, the last Artifactory build number is used.
- build_url (
str
):The orchestrator build URL.It can be the URL of the Jenkins pipeline of the build, for example.
- local_folder (
str
):The local folder that contains the files to upload. - config_file (
str
) - Required:The path to the configuration file that contains the credentials to the artifact repository. - repository (
str
) - Required:The name of the artifact manager repository to store the build. - repository_path (
str
) - Required:The root path of the repository to store the build (required for Nexus).It is replaced by build_name if it is not specified.
- upload_type (
str
):The following upload types are available:folder
to upload the whole content of the local folder to the artifact repository manager with the content of the local file and with the same folder structure. The created application manifest will reflect the content of the local folder.archive
(default value) to upload and archive the whole content of the local folder in a .tar file in the artifact repository manager. This .tar file can be used only in a static deployment.
The file attributes on z/OS, such astags
andowner
, are preserved. This is important to know when you use this package at deployment time.
Note: For Artifactory, an Artifactory Build Info is always created, unless--buildName
is not specified. - log_config_file (
str
):The logging configuration file to customize the default log file. - working_folder (
str
):The path to the working folder.By default, it is the tmp folder of the operating system.
- manifest_name (
Example
You can copy and paste the following Python sample to call the API. Edit the lines to adapt them to your needs.
from wazideploy.service.wd_services import package
from wazideploy.exception.exception import WD_Exception
import traceback
import sys
def main():
try:
rc, stdout,stderr = package(manifest_name="TEST",
manifest_version="1.0.1",
manifest_description="Test",
build_name="sys-wazi-deploy-team/wazideploy-test-ibm-api",
repository="sys-wazi-deploy-team-pentest-generic-local",
manifest="C:/WD_Inputs/manifest_state_ibm-apivero.yml",
config_file="C:/WD_Config/config.yml",
#log_config_file="C:/WD_Config/config.yml",
local_folder="C:/WD_Inputs/input_files ",
upload_type="folder"
)
print (f">>>>return code : {rc}")
print(f">>>> stdout: {stdout}")
print(f">>>> stderr: {stderr}")
except WD_Exception as ex:
print (">>>>Package error :")
print(f">>>> rc: {ex.rc}")
print(f">>>> stdout: {ex.stdout}")
print(f">>>> stderr: {ex.stderr}")
if ex.exc:
print(f">>> exc:")
print(traceback.print_exception(ex.exc))
if __name__ == '__main__':
main()