Builds by Ant

Hi,

I am using Ant for builds but as per version 2.0, I am not able to write proper command for that. Currently, I’m using this command
ant -lib lib/ Build

But it saying on commiting /bin/bash: ant: command not found

Please help me.

1 Like

Hello,

I think what is likely happening is you are installing ant in one run statement and utilizing it in another. In your config.yml, every run uses /bin/bash -eo pipefail as it’s default shell, which does not possess the --login switch.

https://circleci.com/docs/2.0/configuration-reference/#default-shell-options

You can modify the shell so that it is a login shell as stated in the docs above, or run the install and following command in a single, multi-line run statement.

Hi Kyle,
Thanks for your response but That could not work for me. As I am using this command for 1.0 working fine for me

test:
override:
- ant -lib lib/ Build:
timeout: 600
How can I convert it into 2.0

1 Like

I am facing exact same issue as well. I could not find any solution yet!

Please provide the solution for that.

What code do you have, what errors are you getting? The first post suffers from being rather unclear, so someone somewhere is going to have to give a clear and detailed explanation :stuck_out_tongue_winking_eye:

I was using this 1.0 config -

     machine:
          node:
            version: 4.1.0
          java:
            version: oraclejdk8
        dependencies:
          override:
            - npm install -g gulp
            - npm install -g bower
            - npm install
            - bower install
            - gulp sf-bundle:spa
        test:
          override:
            - ant -lib lib/ -buildfile build/build.xml Build: 
                pwd: ../../
                timeout: 600
        general:
          build_dir: project/src
          branches:
            ignore:
                - dev.eblazer

I have converted into 2.0 like -

version: 2.0
jobs:
  build:
    docker: 
      - image: circleci/node:4.8.2
      - image: circleci/java:8-jdk
    steps:
      - checkout

      - run:
          name: Install -g gulp
          command: sudo npm install -g gulp

      - run:
          name: Install -g bower
          command: sudo npm install -g bower  

      - run:
          name: npm Install
          command: sudo npm install
          working_directory: project/src 

      - run:
          name: bower Install
          command: bower install
          working_directory: project/src
      - run: 
          name: ant -lib lib/ -buildfile build/build.xml
          command: ant -lib lib/ -buildfile build/build.xml

Please see attached screenshot for the issue detail -

Hmm, do you need to install Ant explicitly? If not, find out where it is being installed (e.g. if it is part of the JDK) and call it /with/the/full/path/to/ant.

You can get an SSH session on a failed build to have a poke around, if that is helpful.

lib/ is the path of ant which contains ant-salesforce.jar file

No no, it’s having trouble finding ant itself. You need to find that binary, assuming it is installed at all.

You can see in screenshot, circleci/java:8-jdk could not be installed. You know, ant could not be run without java jre.

I am not sure what you are saying. Are you saying that you know this container has a copy of Ant? I do not share your confidence, and I think the next thing that you need to do is to SSH into the running container and have a look. Would you try that now?

(One important thing with CI, and indeed coming here for help, is that folks with a problem need to be persistent and highly self-directed. Statements that amount to “it does not work” are not likely to attract more assistance. :slight_smile:)

Oh, just spotted this:

      - image: circleci/node:4.8.2
      - image: circleci/java:8-jdk

This means:

  • Node is your primary build container
  • Java JDK is your secondary build container, which you can contact over HTTP (if there is a server running)

So, the question is, does the circleci/node image contain Ant? My guess is that the JDK image is spinning up and then doing nothing.

You may find some benefit in explaining what you’re trying to do with these images.

Thanks! I got the hint to solve this issue.
I need to user docker image circleci/java:8-jdk, which will make environment to run ant. And to work with the node module, I will manually install node. Now, updated config.yml

version: 2.0
jobs:
  build:
    docker:
      - image: circleci/openjdk:8-jdk
    steps:
      - checkout
      - run:
          name: Download Node
          command: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash

      - run:
          name: Install Node
          command: sudo apt-get install -y nodejs    

      - run:
          name: Install -g gulp
          command: sudo npm install -g gulp

      - run:
          name: Install -g bower
          command: sudo npm install -g bower  

      - run:
          name: npm Install
          command: sudo npm install
          working_directory: src/project 

      - run:
          name: bower Install
          command: bower install
          working_directory: src/project
      
      - run: 
          name: ant -lib lib/ -buildfile build/build.xml
          command: ant -lib lib/ -buildfile build/build.xml
1 Like

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