# Natural Ant Deploy using Azure Pipeline

**URL:** <https://techcommunity.softwareag.com/t/natural-ant-deploy-using-azure-pipeline/280290>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes, Natural-on-Linux, NaturalONE, azure, pipeline\
**Created:** [June 25, 2023, 11:19pm UTC](https://techcommunity.softwareag.com/t/natural-ant-deploy-using-azure-pipeline/280290 "2023-06-25T23:19:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trentan\_Healey](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/trentan_healey/32/7009_2.png) [@Trentan\_Healey](https://techcommunity.softwareag.com/u/Trentan_Healey)\
**Post date:** [June 25, 2023, 11:19pm UTC](https://techcommunity.softwareag.com/t/natural-ant-deploy-using-azure-pipeline/280290/1 "2023-06-25T23:19:13Z")

</div>

Hi all,

Trying to establish a pipeline template in Azure for automated deploys on commit (to certain branch names).  
Need some help with the following. (Perhaps once completed will form a base point for Azure deploys, like the Jenkins example in the NaturalOne help).  
Is there a pipeline expert who might be able to help (or i’ll keep fumbling around until I can solve it).  
Example:

## azure-pipelines.yml

# Ant Script for TripsNat deploy for committed files

trigger:

- Dev

pool:  
vmImage: ubuntu-latest

# Use a separate repo location of resources for use in the ant script below - holds the jars required for publish

# These jars are REFERENCED in the lib options for the ant script below (perhaps need to be copied to the working directory?)

resources:  
repositories:

- repository: softwareag/november2022  
type: nexus  
name: softwareag/november2022

steps:

- script: echo Trying nat deploy to  
displayName: ‘test deploy’

# Use a task to download the previously created artifact (files below) from last successful run into the tripsnat main dir for Ant execution: cache\_deploy.properties, history\_deploy.txt, timestamp\_deploy.properties

# After ant execution, these files need to republished again (as modified from the Ant run)

- task: DownloadPipelineArtifact@2

# Copy the downloaded artifact files from previous step into the working directory

- task: CopyFiles@2

# Ant execution

- task: Ant@1  
inputs:
# Here the referenced repo for the jars required is used in the ant script - these might need to reside somewhere in the working directory perhaps
options: ‘-lib $(Softwareag/november2022)’  
buildFile: ‘deploy.xml’  
javaHomeOption: ‘JDKVersion’  
jdkVersionOption: ‘1.8’  
jdkArchitectureOption: ‘x64’  
publishJUnitResults: true  
testResultsFiles: ‘\*\*/TEST-\*.xml’

# Publish the updated files as artifact for next run: cache\_deploy.properties, history\_deploy.txt, timestamp\_deploy.properties

- task: PublishPipelineArtifact@2

---

<div class="post-metadata">

**Author:** ![Trentan\_Healey](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/trentan_healey/32/7009_2.png) [@Trentan\_Healey](https://techcommunity.softwareag.com/u/Trentan_Healey)\
**Post date:** [August 3, 2023, 1:06am UTC](https://techcommunity.softwareag.com/t/natural-ant-deploy-using-azure-pipeline/280290/2 "2023-08-03T01:06:42Z")

</div>

Hi all, I solved this with the following.

**NOTE** As we have incremental deploys - I had to ensure the moving agent and pool was handled (hence the bash script to deal with the change in the cache properties file… ALSO azure checks out our git repo WITHOUT the name and directly to the working directory (so handled…)

We have the sysobjh uploading to the mainframe too for review and migrating to other environments as required.

Hope this helps others, enjoy.

```auto
trigger:
- Dev

pool:
  name: Prod-BuildPool

## Checkout of the repo occurs by default in azure

stages:
  - stage: SetupDeployNaturalMainframeModules
    jobs:
## Download the last successful built artifact for Ant deploy (includes properties files and jars). This is loaded into the targetPath.
    - job: performBuildAndDeployNatural
      steps:
        - task: DownloadPipelineArtifact@2
          inputs:
            buildType: 'specific'
            project: '$(System.TeamProject)'
            buildVersionToDownload: 'latestFromBranch'
            pipeline: 'natural'
            branchName: 'refs/heads/E1'
            artifactName: 'natDeployProperties'
            targetPath: '$(System.DefaultWorkingDirectory)'

## The following jars are required in the lib options for the ant script below (we store the jars in a local hosted nexus repo)
## https://nexus.bcz.gov.au/service/rest/repository/browse/IMMI_RAW/softwareag/november2022/ (curl commands below)
## NOTE: These are bundled in published artifacts, so no need to perform CURL these fetches again (only if version changes to republish to the trailing artifact)
      # steps:
      # - bash: |
      # curl -o com.ibm.icu.charset_4.8.1.jar http://nexus.bcz.gov.au/repository/IMMI_RAW/softwareag/november2022/com.ibm.icu.charset_4.8.1.jar -O -J -L
      # curl -o com.ibm.naturalone.icu_4.8.1.jar http://nexus.bcz.gov.au/repository/IMMI_RAW/softwareag/november2022/com.ibm.naturalone.icu_4.8.1.jar -O -J -L
      # curl -o com.softwareag.natural.tools_9.2.1.0000-0304.jar http://nexus.bcz.gov.au/repository/IMMI_RAW/softwareag/november2022/com.softwareag.natural.tools_9.2.1.0000-0304.jar -O -J -L
      # curl -o com.softwareag.naturalone.natural.ant_9.2.1.0000-0304.jar http://nexus.bcz.gov.au/repository/IMMI_RAW/softwareag/november2022/com.softwareag.naturalone.natural.ant_9.2.1.0000-0304.jar -O -J -L
      # curl -o com.softwareag.naturalone.natural.auxiliary_9.2.1.0000-0304.jar http://nexus.bcz.gov.au/repository/IMMI_RAW/softwareag/november2022/com.softwareag.naturalone.natural.auxiliary_9.2.1.0000-0304.jar -O -J -L
      # curl -o com.softwareag.naturalone.natural.ndvserveraccess_9.2.1.0000-0304.jar http://nexus.bcz.gov.au/repository/IMMI_RAW/softwareag/november2022/com.softwareag.naturalone.natural.ndvserveraccess_9.2.1.0000-0304.jar -O -J -L

## This script replaces the current user agent for the cache_deploy_.properties file so the ant script can check for module changes, formatted to match file!
        - bash: |
            file='$(System.DefaultWorkingDirectory)/cache_deploy_.properties'
            userAgent='$(System.DefaultWorkingDirectory)'
            userAgent=${userAgent//\\/\\\\}
            userAgent=${userAgent//:/\\:}\\\\
            echo "User agent being updated:" $userAgent
            sed -i -e '2,$s/^[^s]*s\\\\/'"${userAgent//\\/\\\\}/" "$file"
          name: adjustUserAgent
          displayName: 'Adjust cache properties files to current user agent'

## Ant execution (Mainframe deploy magic)
        - task: Ant@1
          env:
            JAVA_HOME: 'D:\Software-tools\JDK\Open\jdk-11' ## The jars from above require JDK 11
          inputs:
            ## The project in Azure is checked out WITHOUT a project name, so setup Ant to run without a project name
            options: '-lib $(System.DefaultWorkingDirectory) -Dnatural.ant.project.rootdir= -Dnatural.ant.project.name='
            buildFile: 'deploy.xml'
            publishJUnitResults: true
            testResultsFiles: '**/TEST-*.xml'

## After ant execution (modifies files), these files need to published as an artifact again (as modified from the Ant run)
        - task: CopyFiles@2
          inputs:
            SourceFolder: '$(Pipeline.Workspace)'
            Contents: |
              **/cache_deploy_.properties
              **/history_deploy_.txt
              **/timestamp_deploy_.properties
              **/com.ibm.icu.charset_4.8.1.jar
              **/com.ibm.naturalone.icu_4.8.1.jar
              **/com.softwareag.natural.tools_9.2.1.0000-0304.jar
              **/com.softwareag.naturalone.natural.ant_9.2.1.0000-0304.jar
              **/com.softwareag.naturalone.natural.auxiliary_9.2.1.0000-0304.jar
              **/com.softwareag.naturalone.natural.ndvserveraccess_9.2.1.0000-0304.jar
            TargetFolder: '$(Build.ArtifactStagingDirectory)'
            flattenFolders: true

        - task: PublishBuildArtifacts@1
          displayName: 'Publish Artifact properties'
          inputs:
            ArtifactName: natDeployProperties

### TODO These FILES could be added to a separate branch (or repo) - can checked out and committed rather than the artifact method...
              # **/cache_deploy_.properties
              # **/history_deploy_.txt
              # **/timestamp_deploy_.properties
'''
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 30, 2024, 1:07am UTC](https://techcommunity.softwareag.com/t/natural-ant-deploy-using-azure-pipeline/280290/3 "2024-01-30T01:07:16Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
