Skip to content

The easiest way to get build version information from git into your application.

License

Notifications You must be signed in to change notification settings

pixio/PXBuildVersion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PXBuildVersion

Version License Platform

The easiest way to get build version information from git into your application.

PXBuildVersion is a set of scripts to generate build version information about your application. This includes the build date, version control information (git commit sha, branch, and tag), and any other environment variables captured at build time.

Supports Jenkins CI, Travis CI, and Circle CI build numbers.

Installation

PXBuildVersion is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PXBuildVersion'

You will also need to add a build script. The easiest way to do this is to add a post_install hook to your Podfile. If you already have a post_install section in your Podfile, add just the contents to the existing post_install as only one post_install hook is allowed per Podfile.

post_install do |installer|
  if File.exists?('Pods/PXBuildVersion')
    require_relative 'Pods/PXBuildVersion/scripts/util/setup.rb'
    pxbuildversion_setup(installer)
  end
end

Once your Podfile is correctly configured, simply run pod install to install!

Usage

It's simple to use!

Objective-C

NSLog(@"git sha: %@", [PXBuildVersion commit]);
if ([PXBuildVersion tag] != nil) {
    NSLog(@"git tag: %@", [PXBuildVersion tag]);
}

Swift

if let commit = PXBuildVersion.commit() {
    print("git sha: \(commit)")
}
if let tag = PXBuildVersion.tag() {
    print("git tag: \(tag)")
}

Add it to your settings pages. Or, add it to your crash reporting tool to help track down issues!

[[Crashlytics sharedInstance] setObjectValue:[PXBuildVersion commit] forKey:@"commit"];

Configuration

By adjusting the setup script, you can control the environment variables that are generated in the version payload.

Options

    -e, --env [NAMES]                Comma separated list of env variable names
        --all-env                    Dump all environment env variables found
        --exclude-default            Exclude default env variables

These options can be applied to the setup script in the Podfile.

Example

Update the pxbuildversion_setup line in your Podfile to specify the exact script, specifying any options.

if File.exists?('Pods/PXBuildVersion')
  require_relative 'Pods/PXBuildVersion/scripts/util/setup.rb'
  pxbuildversion_setup(installer, script: %(\"${PODS_ROOT}/PXBuildVersion/scripts/git.rb\" -e NODE_NAME,BUILD_URL --exclude-default))
end

Then access any captured environment variables as needed:

if let buildNode = PXBuildVersion.environmentVariables()["NODE_NAME"],
       buildUrl = PXBuildVersion.environmentVariables()["BUILD_URL"] {
    print("This was built by Travis CI on node: \(buildNode)")
    print("Access the build job details at: \(buildUrl)")
}
else {
    print("Perhaps we should automate our builds with a CI server")
}

Author

kwongius

License

PXBuildVersion is available under the MIT license. See the LICENSE file for more info.

About

The easiest way to get build version information from git into your application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published