uss_copy

This building block copies artifacts to a z/OS UNIX System Services directory. It creates the directory if it does not exist.

It is run on the artifacts that are listed under the step that it implements in The deployment plan.

To trigger the execution of this building block, you can enter the following code in the deployment method from which the deployment plan is generated. See How to trigger the execution of a building block. The following code is an example.
actions:
    - name: COPY ARTIFACTS TO A USS DIRECTORY
      short_name: COPY_TO_USS
      steps:
      - name: TEST STEP FOR USS_COPY
        short_name: TEST_USS_COPY
        properties:
        - key: template
          value: uss_copy

types:
  - name: 'BIN'
  - name: 'TXT'
  - name: 'SH'
is_artifact: True

This building block is related to the following artifact types: UNIX or LINUX shell executable file, binary file, and text file in this example. However, it can be any type of artifact that you want to manage. The names that you give to these artifact types correspond to the extensions of these artifacts in the package file. You can freely choose these extension names.

To run correctly, this building block requires environment variables. Indicate them in a .yml file. Indicate The generic environment variables for the Ansible and Python building blocks and adapt their values to your target z/OS environment. Indicate also the variables that are specific to this building block.

The Ansible variables

To run this building block, indicate the following specific variables in an Ansible environment variables file:
uss_root_folder: '/tmp/wd_uss'

default_types: 'types'

types:
  - type: 'bin'
    uss: 
      dest: "{{ uss_root_folder }}/bin/"
      backup_dest: "{{ uss_root_folder }}/bin/back/"
      dest_mode: '0777'
      artifact_mode: '0755'
    is_binary: True
  - type: 'txt'
    uss: 
      dest: "{{ uss_root_folder }}/txt/"
      backup_dest: "{{ uss_root_folder }}/txt/back/"
      dest_mode: '0777'
      artifact_mode: '0755'
  - type: 'sh'
    uss: 
      dest: "{{ uss_root_folder }}/sh/"
      backup_dest: "{{ uss_root_folder }}/sh/back/"
      dest_mode: '0777'
      artifact_mode: '0755'

Among all the variables that are shown in this extract, only some of them are used by this building block. The other variables are included so that you can copy and paste all the variables that might be relevant for other building blocks. To run this building block, you must declare the variables related to the artifact types.

Enter the name of the root that lists the types and characteristics of the artifacts to be deployed, if the building block applies to artifacts. By default, the root name is types but you can enter any other name if you define a var_type property in the deployment method step that is implemented by the building block. See The types variable.

Under this root, create a type variable for each artifact type that relates to this building block in the generated deployment plan. The value of each artifact type comes from the deployment method, where it is freely chosen.

For each type variable, enter the following variables:
  • A uss variable with the following embedded variables:
    • A dest variable to specify the whole path to the destination z/OS UNIX System Services directory.
    • A dest_mode variable to specify the permission on the backup z/OS UNIX System Services directory.
    • An artifact_mode variable to specify the permission on the artifacts.
  • An encoding variable if an encoding is needed. To indicate an encoding, you must specify the following variables: from for the initial encoding and to for the target encoding.
  • An is_binary variable that is set to True to specify that the artifact type corresponds to a binary file. It is mandatory for all the binary files.
  • A text_subs if you want to use text substitution for artifacts that are not binary files (is_binary: False). You can substitute a pattern, which is a regular expression, by a replacement text before the copy.
    For example, you can enter the following code:
    - type: 'txt'
        uss: 
          dest: "{{ uss_root_folder }}/txt/"
          backup_dest: "{{ uss_root_folder }}/txt/back/"
          dest_mode: '0777'
          artifact_mode: '0755'
      encoding:
        from: UTF-8
        to: IBM-1047
      text_subs:
      - pattern: "#SUB1"
        replace: "01"
      - pattern: "#SUB2"
        replace: "02"
      - pattern: "#SUB3"
        replace: "03"
  • A rename_subs variable if you want to rename some artifacts for the deployment. Then, the building block will process these artifacts under names that are different from the names in the application package.

    In the following example, pattern and replace are regular expressions.

    - type: 'txt'
        uss: 
          dest: "{{ uss_root_folder }}/txt/"
          backup_dest: "{{ uss_root_folder }}/txt/back/"
          dest_mode: '0777'
          artifact_mode: '0755'
      encoding:
        from: UTF-8
        to: IBM-1047
      rename_subs:
      - pattern: "CDRD(.*)"
        replace: "CDRP\1"

The Python variables

To run this building block, indicate the following specific variables in a Python environment variables file. The whole path to this file is indicated in the --envFile argument of The Python deployment command.

uss_root: '/tmp/uss_root'
types:
  - pattern: .*.BIN$
    directory: "{{ uss_root }}/bin/"
    directory_backup: "{{ uss_root }}/bin/back/"
    dest_mode: 0777
    artifact_mode: 0755
    is_binary: True
  - pattern: .*.SH$
    directory: "{{ uss_root }}/sh/"
    directory_backup: "{{ uss_root }}/sh/back/"
    dest_mode: 0777
    artifact_mode: 0755
  - pattern: .*.TXT$
    directory: "{{ uss_root }}/txt/"
    directory_backup: "{{ uss_root }}/txt/back/"
    encoding:
      from: UTF-8
      to: IBM-1047
    dest_mode: 0777
    artifact_mode: 0755 

Among all the variables that are shown in this extract, only some of them are used by this building block. The other variables are included so that you can copy and paste all the variables that might be relevant for other building blocks. To run this building block, you must declare the variables related to the artifact types.

Enter the name of the root that lists the types and characteristics of the artifacts to be deployed, if the building block applies to artifacts. By default, the root name is types but you can enter any other name if you define a var_type property in the deployment method step that is implemented by the building block. See The types variable.

Under this root, create a pattern variable for each artifact type that relates to this building block in the deployment plan. The value of each artifact type comes from the deployment method, where it is freely chosen. A pattern is a regular expression that selects the artifacts from their path in The application manifest file.

Enter the following variables for each pattern variable:
  • A directory variable to specify the name of the destination z/OS UNIX System Services directory.
  • A dest_mode variable to specify the permission on the backup z/OS UNIX System Services directory.
  • An artifact_mode variable to specify the permission on the artifacts.
  • An encoding variable if an encoding is needed. To indicate an encoding, you must specify the following variables: from for the initial encoding and to for the target encoding.
  • An is_binary variable that is set to True to specify that the artifact type corresponds to a binary file. It is mandatory for all the binary files.
  • A text_subs if you want to use text substitution for artifacts that are not binary files (is_binary: False). You can substitute a pattern, which is a regular expression, by a replacement text before the copy.
    For example, you can enter the following code:
      - pattern: .*.TXT$
        directory: "{{ uss_root_folder }}/txt/"
        directory_backup: "{{ uss_root_folder }}/txt/back/"
        encoding:
          from: UTF-8
          to: IBM-1047
        dest_mode: 0777
        artifact_mode: 0755 
        text_subs:
        - pattern: "#SUB1"
          replace: "01"
        - pattern: "#SUB2"
          replace: "02"
        - pattern: "#SUB3"
          replace: "03"
  • A rename_subs variable if you want to rename some artifacts for the deployment. Then, the building block will process these artifacts under names that are different from the names in the application package.
    In the following example, pattern and replace are regular expressions.
      - pattern: .*.TXT$
        directory: "{{ uss_root_folder }}/txt/"
        directory_backup: "{{ uss_root_folder }}/txt/back/"
        encoding:
          from: UTF-8
          to: IBM-1047
        dest_mode: 0777
        artifact_mode: 0755 
        rename_subs:
        - pattern: "CDRD(.*)"
          replace: "CDRP\1"

Return values

The result of each building block task is displayed in the evidence file, in The results level that is embedded in step_result.