using git-lfs in an Xcode Bot

I installed git-lfs on my Xcode Server instance.

I added my hosting server's url to my global gitconfig :


cat ~/.gitconfig

[filter "lfs"]
  clean = git-lfs clean %f
  smudge = git-lfs smudge %f
  required = true
[lfs]
  url = https://artifactory.myCompany.net/artifactory/api/lfs/git-lfs



I added git-lfs to my pre-build trigger :


#!/bin/bash
echo "Initializing dependencies"
export PATH="$PATH:/opt/local/bin:/opt/local/sbin:/usr/local/bin"
git lfs init
#here I run my own git command which pulls my git sources which are using git-lfs
[[ $? -eq 0 ]] || exit 1

cat "$XCS_SOURCE_DIR/Components/OpenSSL/lib/Device/libssl.a"
cat "$XCS_SOURCE_DIR/Components/OpenSSL/lib/Simulator/libssl.a"



The result is :


version https:/

oid sha256:123fb53535365ede0f7b95aaa8cb4be3c38c5f4bac30cd74d4fbe3e283903f54

size 4529280


version https:/

oid sha256:99b51ad7bc89d3f870140644f21c088ebcf6f9627996d9eb9b16c47437a6edfe

size 3153456


So it seems that it is not using git-lfs at all, just pulling down the real file content (the pointers).


Do you know how can this issue be fixed?


Thanks!

Accepted Answer

Simply executing "git lfs pull" solved the issue for me .

How did you install gif-lfs for your Xcode server machine? When I add a trigger that just runs `git-lfs pull`, my integration reports that it doesn't know about `git-lfs`

This solution doesn't seem to apply to Xcode9 Build Server. I did everything as described in the post, my integration fails with this error in log "sudo: no tty present and no askpass program specified". Has anyone solved this?

The accepted solution does not work with Xcode 9. Does anyone have a method that allows git lfs to work with Xcode Server 9?

Doing "git lfs pull" worked for me but I also had to do something to get my github password onto our bot server.

I was getting errors in the script that chrisl777777 posted:

fatal: could not read Password for 'https://XXX@github.com'://XXX@github.com': Device not configured

batch response: Git credentials for https://XXX@github.com/XXXXXX/projectName.git//XXX@github.com/XXXXXX/projectName.git not found.


Here's what I had to do for that to happen. (This info added for posterity of this highly related information.)


You'll need be ON the bot server (live or screen share).

Open a terminal window.

Change directory (cd) to the current directory that has the repo you need to log into.

In the pre-integration script we entered "pwd" on its own line. In the log file that gets output from the bot job, this printed out the working directory. It appeared something like this: /Users/xcodeserver/Library/Caches/XCSBuilder/Bots/fb0e1f46209822b44d99ec60ff0000e6/Source


On the bot server terminal window, we CD'd into the above directory.

Then 'ls' revealed just 1 sub directory: 'iOS' the name of the repo.

CD into that.

Then 'git status' to reveal the branch and status.


Then a git command, in my case used 'git lfs pull'; this required entering my password/Personal Access Token (I have to use the PAT). Copy/Paste is OK in terminal.


The first time this command failed for some reason, downloaded 0bytes. Tried it exactly the same again, and it worked, showing files downloaded.


I also reset the repo in the bot setup (Bot > Repositories > Replace Repositories), I am not sure if that was needed or not.


Unrelated: You can find the bot output at: /HD/Library/Developer/XcodeServer/IntegrationAssets/{some hash numbers-BotName}/{integration-#}

using git-lfs in an Xcode Bot
 
 
Q