This is the fifth day of my participation in the More text Challenge. For details, see more text Challenge

The project address for this article.

Note: This article does not cover the basic configuration of Xcode Server

Xcode Server is a continuous integration solution provided by Apple. Before Xcode 9, you need to download and install OS X Server in the Mac App Store. In Xcode 9, Xcode Server is built into Xcode, greatly simplifying the process of setting up the CI environment.

At the end of an Xcode Server build, you can see various types of data that were generated during the build process. For example, the Commits interface shows the Commits that were added to Git compared to the Commits of the previous integration.

Xcode Server is typically deployed on a separate Mac, and when it needs to be packaged, merge the code into the specified branch and Xcode Server will be packaged automatically.

After the build is complete, how do you inform the developers, testers, and project leaders about the build? Have all the staff stare at the information on Xcode Server? Obviously it’s most convenient to push a message into the company’s communication tool (nail) and @ the person concerned.

Here is the final implementation presentation, with the output as detailed as possible about the build: compile information, upload dandelion information, code change logs, @ associated personnel.

Note: Xcode Server provides the function of directly downloading and installing the App, but you need to access the App through HTTPS, so you need to ensure that the mobile phone and Xcode Server are on the same network segment, or deployed in an HTTPS environment. If there is no guarantee, then consider uploading the IPA to dandelion distribution platform.

Here’s how to extract relevant information from a nail message.

How do I extract compile information

Xcode Server provides a number of environment variables that can be used directly after the build.

How do I extract version information

This section of information is returned after the IPA is submitted to the dandelion via the API.

How does the code commit records

The first thing to note is that Xcode Server pulls a copy of the code from the Git repository into its own dedicated project path, which is not the same as the project path we pulled.

The environment variable XCS_PRIMARY_REPO_DIR provides the path to the source code repository for Xcode Server’s workspace. You can use the Python library Repo to get Git commit information.

But how do you get the commit information for this build relative to the last new commit? How do you get the last commit information from the last build?

The environment variable XCS_OUTPUT_DIR provides a top-level directory for the resources (including logs and products) stored during Xcode Server integration. ‘XCS_OUTPUT_DIR’ + “/ sourcecontrol. log” is the log information for the local build.

/ / a log information DVTSourceControlWorkspaceBlueprintLocationsKey = {B18B82A392A550FBEAB693A1A84AE2228193F564 = { DVTSourceControlBranchIdentifierKey = master; DVTSourceControlBranchOptionsKey = 4; DVTSourceControlBranchRemoteNameKey = origin; DVTSourceControlLocationRevisionKey = f7c3ccf7d8678fb26ae3700e747e057bd0b17c0f; DVTSourceControlWorkspaceBlueprintLocationTypeKey = DVTSourceControlBranch; }; };Copy the code

Which DVTSourceControlLocationRevisionKey node contains the last commit build time information.

Git commit information

  1. The environment variableXCS_PRIMARY_REPO_DIRIs the source path of Xcode Server;
  2. Python libraryRepoCan be used to bring up commit information;
  3. sourceControl.logDVTSourceControlLocationRevisionKeyContains the commit information for the last build.

This article’s project address, you can see all the relevant code.