Jenkins Pipeline for Unity iOS

Cem Ayan
3 min readMay 12, 2021

Jenkins an open source automation server which enables developers around the world to reliably build, test, and deploy their software.

Today, I’ll show how we can create Jenkins pipeline for Unity iOS.

  • Firstly, We should create a new pipeline project.
  • We have to select “Pipeline script from SCM” as pipeline definition.

We can choose path to Jenkinsfile and branch

If we want to build when a change is pushed to Bitbucket, we have to check this option.

We must define a webhook to our git provider.

  • To access our repository, we should create a new credential.
  • We need our SSH private key. If you haven’t SSH key, you can create it with the code below.
ssh-keygen
cat ~/.ssh/id_rsa | pbcopy
  • We should add SSH private key to Jenkins credential provider.
  • Then, we should add SSH public key to our git provider such as Github, Bitbucket, etc. You can access it with the code below.
cat ~/.ssh/id_rsa.pub | pbcopy

We need to check Unity, Certificates before create Jenkinsfile

Now, this part is very import.

  • To execute Unity “executeMethod” parameter, we should create a new class such as BuildActions.cs
Assets/Editor/BuildActions.cs

Our Jenkinsfile will consist of 6 stage.

  • iOSBuild

You can find Unity cli commands on this link.

  • iOSClean
  • iOSArchive
  • iOSIPA

exportOptions.plist

  • iOSS3(Optional)
  • iOSTestFlight
  • Jenkins Global Env

If you want to full file of Jenkinsfile, you can download from this link.

  • We uploaded to S3 in the previous step and we want to receive mail when coming to file to S3. (Optional) We should create Event notification for this situation
  • Then, AWS Lambda function triggered when uploading to S3. The following function is used to read the incoming event.
  • To send the mail, we should verify a email address (AWS SES)
  • May be you want to notify Slack. You should install Slack Notification Plugin. Then you should define Slack credential.
  • You can send the notification with the following code.
def attachments = [
[
text: 'I find your lack of faith disturbing!',
fallback: 'Hey, Vader seems to be mad at you.',
color: '#ff0000'
]
]

slackSend(channel: "#general", attachments: attachments)

If all stage succeed, you can see like the following picture.

I hope you liked it. Feel free to ask question :)

--

--