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 7532801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:33:26+00:00 2026-05-30T05:33:26+00:00

Our internal build system uses a shell script to setup the environment for building

  • 0

Our internal build system uses a shell script to setup the environment for building projects. Then the actual build tools (ant or make) can reference environment variables for configuring various things. In essence, it does:

$ /path/to/setup_env.sh .
[build env] $ ant compile

Note that the first command launches and initializes a new shell and expects all subsequent build operations to be performed in that shell.

Now I am trying to replicate the same within Jenkins. How do I run a shell script and then have the subsequent ant build step take place in the same environment?

The ‘Execute Shell’ built-in as well as the EnvInject plugin didn’t help since they discard any changes to the environment before moving to the next build step.

I’d prefer not to modify the ant build file since the same should continue to work in the current internal build system.

  • 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-05-30T05:33:28+00:00Added an answer on May 30, 2026 at 5:33 am

    This is a “solution” that worked out for us. The key idea is that the setup_env.sh script launches a new shell in which it exports a bunch of environment variables. What we needed was access to those variable definitions. So we did a three part Jenkins Build:

    Step 1 – Execute Shell

    Use the ‘Execute Shell’ Jenkins built-in to run our setup_env.sh script. Then feed the newly launched shell a simple python script that dumps the environment to a file.

    /path/to/setup_env.sh . <<< 'python <<SC
    print "Exporting env to buildenv.properties file"
    import os
    f = open("buildenv.properties", "w")
    env = os.environ
    for k in env:
      f.write("%s=%s\n" % (k, env[k]))
    f.close()
    print "Done exporting env"
    SC'
    

    Step 2 – Inject Environment Variables

    Now we use the EnvInject Plugin to inject environment variables from the file dumped in the previous step. The config here is simple, just specify the dumped properties file name as the Properties File Path field value.

    Step 3 – Invoke Ant

    Here, we kick off the normal ant build. Since the environment now contains all the required definitions, the build completes as normal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a search for our internal support database - each support
We have an SVN repository hosted externally and our build server is currently internal.
We have an Ant and Ivy-based build management system, which basically consists of a
I have an Ant build script to generate some classes. The process requires an
I built an internal project management system for our office. The system has functioned
I'm trying to implement an internal chat system for our admins to use, but
I am trying build an automated testing framework for some of our internal web
Our shop is in the process of converting our internal project management application from
We are making a Jabber client for our internal use in our company and
I have started upgrading one of our internal software applications, written in ASP.NET Web

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.