SergiBC
SergiBC

Reputation: 533

Undefined method uploading apk with Fastlane

I'm getting an error on gitlab ci server deploying/uploading an apk to Fabric with Fastlane. The strange thing is that it is working if I run the task from my local. The Fastlane is the same version in both cases 2.123.0.

The method of the task that is failing is:

31 desc "Generate QA release notes"
32 private_lane :qa_release_notes do 
33 commit = last_git_commit 
34 short_hash = commit[:abbreviated_commit_hash] 
35 author = commit[:author] 
36 message = commit[:message] 
37 "Release notes of commit " + short_hash + " by " + author +":\n " + message 
38 end

And the error printed in the ci log is:

[15:43:34]: Error in your Fastfile at line 34
[15:43:34]: 32:  private_lane :qa_release_notes do
[15:43:34]: 33:  commit = last_git_commit
[15:43:34]: => 34:   short_hash = commit[:abbreviated_commit_hash]
[15:43:34]: 35:  author = commit[:author]
[15:43:34]: 36:  message = commit[:message]

(...)

Fastfile:34:in block (2 levels) in parsing_binding': [!] undefined method []' for nil:NilClass (NoMethodError)
    from /var/lib/gems/2.3.0/gems/fastlane-2.123.0/fastlane/lib/fastlane/lane.rb:33:in `call'

It seems the problem is with the method commit[:abbreviated_commit_hash] But I don't know what the problem is...Any idea?

Upvotes: 0

Views: 1438

Answers (2)

SergiBC
SergiBC

Reputation: 533

The error was the last_git_commit was getting an empty result (as @janpio said here) because for some reason the git was missing in the Docker image.

Upvotes: 0

janpio
janpio

Reputation: 10902

I think the error message tells you that commit = last_git_commit didn't actually set commit to anything, so using [...] on it raises [!] undefined method []' for nil:NilClass (NoMethodError).

You could try to debug by simply outputting commit between lines 33 and 34: puts(commit). Running the lane with --verbose might also give some additional, hopefully helpful output to understand what is going on.

The code being executed in the background is actually https://github.com/fastlane/fastlane/blob/4c468b9873f9a2bd68e8ef21b2502d32f2024d32/fastlane/lib/fastlane/helper/git_helper.rb#L53-L74, but I don't see an obvious way why this would be failing on gitlab CI.

Upvotes: 1

Related Questions