Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49600

Ant in pipeline DSL doesn't import env vars correctly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • ant-plugin
    • None
    • Jenkins ver. 2.89.3
      Ant Plugin 1.8
      Build slave OS CentOS 7.2
      Ant 1.9.2

      The DSL

       

      pipeline {
          agent {
              node {
                  label 'lowpriority'
              }
          }
          environment {
              BRANCH_NAME = 'feature/jenkins-pipline-poc'
          }
          tools {
              ant 'Ant 1.9'
              jdk 'wca-jdk-prod'
          }
          stages{
              stage ('Checkout') {
                  steps {
                      cleanWs()
                      checkout scm
                  }
              }
              stage ('Build') {
                  
                  steps {
                     sh "ant clean -v"
                  }
              }
          }
      }
      

      Ant property "build-common-ant.dir" depends on ENV vars "NODE_NAME" and "EXECUTOR_NUMBER"

      It get following errors

      [property] Loading Environment env.
      Property "NODE_NAME" has not been set
      Property "EXECUTOR_NUMBER" has not been set
      

      It works if I modify the ant step like this.

      steps {
         sh '''#!/bin/bash
               env > env.props
               source env.props
               ant clean -v
            '''
      }
      

            armfergom Armando Fernandez
            samarth2892 Samarth Patel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: