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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: ant-plugin
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.89.3
      Ant Plugin 1.8
      Build slave OS CentOS 7.2
      Ant 1.9.2
    • Similar Issues:

      Description

      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
            '''
      }
      

        Attachments

          Activity

          samarth2892 Samarth Patel created issue -
          samarth2892 Samarth Patel made changes -
          Field Original Value New Value
          Description The DSL

           
          {code:java}
          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"
                      }
                  }
              }
          }
          {code}
          Ant property "build-common-ant.dir" depends on ENV vars "NODE_NAME" and "EXECUTOR_NUMBER"

          It get following errors
          {code:java}
          [property] Loading Environment env.
          Property "NODE_NAME" has not been set
          Property "EXECUTOR_NUMBER" has not been set
          {code}
          It works if I modify the ant step like this.
          {code:java}
          steps {
             sh '''#!/bin/bash
                   env > env.props
                   source env.props
                   ant clean -v
                '''
          }
          {code}
           

           

           

           

           

           

           
          The DSL

           
          {code:java}
          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"
                      }
                  }
              }
          }
          {code}
          Ant property "build-common-ant.dir" depends on ENV vars "NODE_NAME" and "EXECUTOR_NUMBER"

          It get following errors
          {code:java}
          [property] Loading Environment env.
          Property "NODE_NAME" has not been set
          Property "EXECUTOR_NUMBER" has not been set
          {code}
          It works if I modify the ant step like this.
          {code:java}
          steps {
             sh '''#!/bin/bash
                   env > env.props
                   source env.props
                   ant clean -v
                '''
          }
          {code}

            People

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

              Dates

              Created:
              Updated: