amguerrero / sfdc_ant_tasks

Salesforce.com ANT Deployment Helper Tasks
14 stars 5 forks source link

Not a git repository (or any of the parent directories): .git #1

Closed TedHusted closed 7 years ago

TedHusted commented 7 years ago

Many thanks for making this library available.

We've been using a Node script to diff deployments, and we'd much prefer to use native Ant.

It's working for me, but only if the basedir is the repository directory.

This requirement is an issue for us, since we use the same Ant build script for several projects, and the build script is in its own repository.

/git ./ant-dx ./survey-force

To keep everyone up to date, we've been checking out the Ant build script and the Salesforce repository next to each other.

If I run deltaDeployment from the Salesforce repository folder ("survey-force"), it's all good.

I'm trying to work around the issue using the Ant task and useNativeBasedir, but it keeps using the basedir from the parent project. https://ant.apache.org/manual/Tasks/ant.html

Is there a way we could add an attribute for the base metadata folder, which might default to ${basedir} if not specified?

<deltaDeployment deltaFolder="${deltaFolder}" previousDeployment="${previousDeployment}" baseFolder="${baseFolder}" />

Here's the stack trace.

Any help you could offer would be appreciated.


DeployDiff: [echo] Preparing DeltaDeployment using ... [echo] deltaFolder="/Users/thusted/git/survey-force/src/deltaFolder" [echo] previousDeployment="master-org" [echo] homedir="/Users/thusted/git/survey-force" [echo] antfile="/Users/thusted/git/survey-force/build-deltaDeployment.xml" [echo]

deltaDeployment: [deltaDeployment] Preparing Delta Deployment file in /Users/thusted/git/survey-force/deltaFolder folder

BUILD FAILED /Users/thusted/git/ant-dx/build-deltaDeploy.xml:43: The following error occurred while executing this line: /Users/thusted/git/ant-dx/build-deltaDeploy.xml:25: The following error occurred while executing this line: /Users/thusted/git/survey-force/build-deltaDeployment.xml:6: java.lang.RuntimeException: fatal: Not a git repository (or any of the parent directories): .git

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at sfanttasks.helpers.GitHelper.getFilesModifiedSince(GitHelper.groovy:9)
at sfanttasks.helpers.GitHelper$getFilesModifiedSince.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at sfanttasks.sfdeltadeployment.SFDeltaDeploymentTask.execute(SFDeltaDeploymentTask.groovy:24)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:854)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
TedHusted commented 7 years ago

Since useNativeBasedir seem broken, I was able to work around using exec. Kludgy but it works.

<target name="DeployDiff" depends="initHome" 
  description="Deploys the minimum amount of metadata to an org by comparing two tags and transferring the difference. Requires: home, sf_credentials, sourceTag, destBranch.).">
  <!-- For now, deltaDeployment needs the metadata repository to be the basedir 
        and so we use an external buildfile to reset the basedir. -->
  <echo file="${homedir}/build.xml" append="false"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><project name="sfDeltaDeployment" basedir="${homedir}" default="deltaDeployment">
<taskdef name="deltaDeployment"
    classpath="${tooldir}/lib/SalesforceAntTasks-with-dependencies.jar"
    classname="sfanttasks.sfdeltadeployment.SFDeltaDeploymentTask" />        
]]> Preparing DeltaDeployment using ... deltaFolder="${deltaFolder}" previousDeployment="${previousDeployment}" homedir="${homedir}" antfile="${homedir}/build.xml"
amguerrero commented 7 years ago

Hi Ted,

thanks for pointing it out, initially I wrote this ant taskdef just with a scenario in mind I was having in a client, so there are a couple assumptions I see now they're not always true, like where from the ant command is run :)

As per what I understood, you have a project structure similar to this: build/ sfdc-project/ (which is a git repository)

I guess you have the build.xml file in build/ directory and it should be able to run the targets no matter where the ant command is being executed, am I right?

I trying to add an optional gitBaseDir property to the ant tasks and use it to run the git command like by adding the argument --git-dir using that gitBaseDir property, I think that way you can run the ant target from any directory.

Would it help you?

amguerrero commented 7 years ago

Hi Ted,

I have just pushed some changes to the repository that add the gitBaseDir attribute to deltaDeployment and addNegativePermisions, this new attribute is meant to be the directory where your local git copy of the Salesforce project is located, it can be an absolute path or a relative path from the directory where the ant target is executed.

Would you mind to give it a try and let me know if it is working now for you?

TedHusted commented 7 years ago

Yes, Manuel, that works perfectly. I very much appreciate the help.