cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get git commit ID of the repository the script runs on?

annagriv
New Contributor II

I have a script in a repository on DataBricks. The script should log the current git commit ID of the repository. How can that be implemented?

I tried various command, for example:

result = subprocess.run(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE, check=True)

but getting the following error:

Command '['git', 'rev-parse', 'HEAD']' returned non-zero exit status 128.

Any help with this will be appreciated 🙏

1 ACCEPTED SOLUTION

Accepted Solutions

-werners-
Esteemed Contributor III

I think this is because of the fact that the code and execution (clusters) are separated.

View solution in original post

3 REPLIES 3

-werners-
Esteemed Contributor III

I think this is because of the fact that the code and execution (clusters) are separated.

annagriv
New Contributor II

Thanks for you reply, so this means its impossible to log the git commit id? There is no way to pass this information to the cluster?

-werners-
Esteemed Contributor III

I think that is indeed the case (not 100% sure as I do not know the innards of Databricks).

The on-demand cluster receives a program to be executed and I don't think a git history is passed.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.