Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:58:56+00:00 2026-06-09T07:58:56+00:00

I am trying to migrate an Ant script I wrote to build and deploy

  • 0

I am trying to migrate an Ant script I wrote to build and deploy projects from within the Jenkins framework (instead of triggered from an SVN post-commit hook, which was the expedient way we initially approached things). Everything is great, except I need to stage files for the deploy step and I want to stuff them into the ‘build’ directory Jenkins creates for the job (and since my build.xml lives in a non-project-specific location, ${basedir} and ${user.dir} do not point to the desired location).

within the Jenkins configuration, I’ve setup the following:

[Jenkins]
Build Record Root Directory: E:/builds/${ITEM_FULLNAME}

[Job-Specific]
Build File: C:\vc-tools\shadow\build.xml

when running a build, the script is appropriately launched and a job-specific build directory is created, e.g.

E:\builds\Test\2012-08-07_12-51-21

I want to get at this directory from within the build script, but cannot figure out how. some of the things I’ve tried:

 [echo] ${basedir}: C:\vc-tools\shadow
 [echo] ${user.dir}: C:\vc-tools
 [echo] ${env.workspace}: C:\Program Files (x86)\Jenkins\workspace\Test
 [echo] ${env.build_id}: 2012-08-07_12-51-21
 [echo] ${jenkins_home}: C:\Program Files (x86)\Jenkins
 [echo] ${BuildDir}: E:/builds/${ITEM_FULLNAME}

note: for that last one, I tried passing in:

 BuildDir=E:/builds/${ITEM_FULLNAME}

as a property configured from the job within Jenkins (clearly ${} expansion doesn’t take place in this context).

according to the documentation, there are no specific environment variables that are set to the full build directory path — I can fudge it by hardcoding the E:\builds root and tacking on ${env.build_id}, but was hoping there would be an easier way to access the complete path from something Jenkins exposes (either an Ant property and an environment variable) in order to make the script more flexible.

I am using Jenkins version 1.476.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:58:58+00:00Added an answer on June 9, 2026 at 7:58 am

    It’s always a good idea for your project to have a copy of it’s build logic included alongside the source code. It makes your build more portable across machines.

    Having said that it’s also quite common to setup build files containing common shared build logic. ANT defines the following tasks to support such activity:

    • include
    • import

    So a possible solution is to store a simple build.xml file, in the root of your project directory:

    <project name="my project" default="build">
    
      <include file="C:\vc-tools\shadow\common-build-1.0.xml" as="common"/>
    
      <target name="build" depends="common.build"/>
    
    </project>
    

    Notes:

    • It’s a good idea to use a revision number in the common build file name. This assists in preserving backward compatibility with other builds using the older logic.

    Update

    When Jenkins runs a job is sets a number of environment variables.

    The following ANT logic will print the location of the Jenkins workspace directory:

    <property environment="env"/>
    
    <target name="run">
        <echo message="Jenkins workspace: ${env.WORKSPACE}"/>
        <echo message="Job directory: ${env.WORKSPACE}../../jobs/${env.JOB_NAME}"/>
        <echo message="Build data: ${env.WORKSPACE}../../jobs/${env.JOB_NAME}/build/${env.BUILD_ID}"/>
    </target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're trying to migrate from current Ant build to Maven. In the current project,
I am trying to migrate to git from svn and it fails by throwing
I am trying to migrate the setup here at the office from SVN to
I am trying to migrate to svn from a not-so-famous version control system (lets
I am trying to migrate a Java application built by Ant to Maven2. Among
I'm trying to migrate from C2DM to GCM, and it mostly works just fine.
I'm trying to migrate a site from a joomla system to a drupal. The
I'm still trying to migrate from CakePHP 1.3 to 2.0 I have a Controller
I'm trying to migrate an existing application from IIS with ServletExec to tomcat. I
I'm trying to migrate my application from Rails 3.0.7 to Rails 3.1.3. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.