Salesforce and Circle CI 2.0 without Salesforce DX

If you are a Circle CI user, you will have noticed the messages in your dashboard that from the End of August you need to migrate to version 2.0

This involves changing your Circle CI script but all of the documentation is for using it with Salesforce DX. To continue using it without Salesforce DX, you will need to create a new yml file. An example of this is below

version: 2

general:

  branches:
    only:
        - master
        - branch1
        - branch2


jobs:
  build:
    working_directory: ~/Folder/Directory
    parallelism: 1
    shell: /bin/bash --login

    docker:
    - image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
      command: /sbin/init
    steps:

    - checkout
    
    - run:
        working_directory: ~/Folder/Directory
        command: sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/jdk1.8.0" >> $BASH_ENV

    - run: ./bin/build.sh

    - run:
        command: ant -lib lib/ Build
        no_output_timeout: 600s

The above file called config.yml needs to be placed in a folder called .circleci

I have added some extra features to the above script which can be remove if they are not needed. For example, this will only build when there is a comment to the following branches: master, branch1, branch2

The location of your jar files, build.xml and package.xml does not change

This also uses the free tier or Circle CI so we can’t cache the imagesĀ  – you can add this if you are using the paid version which will give you faster build times.

Leave a Reply