Natural Ant Deploy using Azure Pipeline

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).


Ant Script for TripsNat deploy for committed files


  • Dev

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?)


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


  • 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:, history_deploy.txt,

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

    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:, history_deploy.txt,

  • task: PublishPipelineArtifact@2

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.

- Dev

  name: Prod-BuildPool

## Checkout of the repo occurs by default in azure

  - stage: SetupDeployNaturalMainframeModules
## Download the last successful built artifact for Ant deploy (includes properties files and jars). This is loaded into the targetPath.
    - job: performBuildAndDeployNatural
        - task: DownloadPipelineArtifact@2
            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)
## (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 -O -J -L
      #       curl -o -O -J -L
      #       curl -o 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 -O -J -L
      #       curl -o 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 -O -J -L

## This script replaces the current user agent for the file so the ant script can check for module changes, formatted to match file!
        - bash: |
            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
            JAVA_HOME: 'D:\Software-tools\JDK\Open\jdk-11' ## The jars from above require JDK 11
            ## 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='
            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
            SourceFolder: '$(Pipeline.Workspace)'
            Contents:  |
            TargetFolder: '$(Build.ArtifactStagingDirectory)'
            flattenFolders: true

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

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

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