This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
213 lines (202 sloc)
7.38 KB
| #!/bin/env groovy | |
| @Library('cliqz-shared-library@vagrant') _ | |
| properties([ | |
| disableConcurrentBuilds(), | |
| [$class: 'JobRestrictionProperty'] | |
| ]) | |
| def jobStatus = 'FAIL' | |
| node('mac-vm-host') { | |
| writeFile file: 'Vagrantfile', text: ''' | |
| Vagrant.configure("2") do |config| | |
| config.vm.box = "browser-ios-v300" | |
| config.vm.define "nightlyios" do |nightlyios| | |
| nightlyios.vm.hostname ="nightlyios" | |
| nightlyios.vm.network "public_network", :bridge => "en0", auto_config: false | |
| nightlyios.vm.boot_timeout = 900 | |
| nightlyios.vm.provider "vmware_fusion" do |v| | |
| v.name = "nightlyios" | |
| v.whitelist_verified = true | |
| v.gui = false | |
| v.memory = ENV["NODE_MEMORY"] | |
| v.cpus = ENV["NODE_CPU_COUNT"] | |
| v.cpu_mode = "host-passthrough" | |
| v.vmx["remotedisplay.vnc.enabled"] = "TRUE" | |
| v.vmx["RemoteDisplay.vnc.port"] = ENV["NODE_VNC_PORT"] | |
| v.vmx["ethernet0.pcislotnumber"] = "33" | |
| end | |
| nightlyios.vm.provision "shell", privileged: false, run: "always", inline: <<-SHELL#!/bin/bash -l | |
| set -e | |
| set -x | |
| rm -f agent.jar | |
| curl -LO #{ENV['JENKINS_URL']}/jnlpJars/agent.jar | |
| ls . | |
| java -version | |
| nohup java -jar agent.jar -jnlpUrl #{ENV['JENKINS_URL']}/computer/#{ENV['NODE_ID']}/slave-agent.jnlp -secret #{ENV["NODE_SECRET"]} & | |
| SHELL | |
| end | |
| end | |
| ''' | |
| vagrant.inside( | |
| 'Vagrantfile', | |
| '/jenkins', | |
| 4, // CPU | |
| 8000, // MEMORY | |
| 12000, // VNC port | |
| false, // rebuild image | |
| ) { nodeId -> | |
| node(nodeId) { | |
| try { | |
| stage('Checkout') { | |
| checkout scm | |
| } | |
| stage('Prepare') { | |
| sh '''#!/bin/bash -l | |
| brew install getsentry/tools/sentry-cli | |
| set -e | |
| set -x | |
| java -version | |
| node -v | |
| npm -v | |
| brew -v | |
| xcodebuild -version | |
| pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | |
| sudo xcodebuild -license accept | |
| gem install fastlane --no-document | |
| fastlane clearCache | |
| fastlane prepare | |
| pip install virtualenv | |
| sudo /usr/bin/easy_install virtualenv | |
| ''' | |
| } | |
| stage('Build & Upload') { | |
| withCredentials([ | |
| [ | |
| $class : 'UsernamePasswordMultiBinding', | |
| credentialsId : '85859bba-4927-4b14-bfdf-aca726009962', | |
| passwordVariable: 'GITHUB_PASSWORD', | |
| usernameVariable: 'GITHUB_USERNAME', | |
| ], | |
| string(credentialsId: '8b4f7459-c446-4058-be61-3c3d98fe72e2', variable: 'ITUNES_USER'), | |
| string(credentialsId: '59474dcc-f87e-41ac-803c-e32a0029f7e7', variable: 'SentryDSN'), | |
| string(credentialsId: '05be12cd-5177-4adf-9812-809f01451fa0', variable: 'FASTLANE_PASSWORD'), | |
| string(credentialsId: 'a1904e28-d791-4118-b8ed-3ff064aee9a4', variable: 'MATCH_PASSWORD'), | |
| string(credentialsId: 'f206e880-e09a-4369-a3f6-f86ee94481f2', variable: 'SENTRY_AUTH_TOKEN'), | |
| string(credentialsId: 'ab91f92a-4588-4034-8d7f-c1a741fa31ab', variable: 'FASTLANE_ITC_TEAM_ID')]) | |
| { | |
| sh '''#!/bin/bash -l | |
| set -x | |
| set -e | |
| rm -rf /Users/vagrant/Library/Keychains/ios-build.keychain* | |
| export MATCH_KEYCHAIN_NAME=ios-build.keychain | |
| rm -rf ../build-tools | |
| fastlane importLocalizations | |
| fastlane nightly | |
| ''' | |
| } | |
| } | |
| jobStatus = 'PASS' | |
| } | |
| catch(all) { | |
| jobStatus = 'FAIL' | |
| print "Something Failed. Check the above logs." | |
| currentBuild.result = 'FAILURE' | |
| } | |
| finally { | |
| stage("Clean Up"){ | |
| sh '''#!/bin/bash -l | |
| set -x | |
| set -e | |
| fastlane clearCache | |
| ''' | |
| } | |
| } | |
| } | |
| } | |
| } | |
| if (jobStatus == 'PASS') { | |
| stage('Update Jira') { | |
| withEnv(['JIRA_SITE=cliqztix']) { | |
| passedBuilds = listOfFailedBuilds(currentBuild) | |
| def issueIds = getIssueList() | |
| def transitionInput = [ | |
| transition: [ | |
| id: '121', | |
| ], | |
| ] | |
| for (id in issueIds) { | |
| try { | |
| def issue = jiraGetIssue idOrKey: id | |
| if (issue.data.fields.status.name == "Resolved") { | |
| jiraTransitionIssue idOrKey: id, input: transitionInput | |
| echo "Transistioned ${id}" | |
| } else{ | |
| echo """Element with id ${id} was not transitioned\nIts status is: """+issue.data.fields.status.name | |
| } | |
| } catch (Error e) { | |
| echo e | |
| } | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Return the list of failed builds up to the latest successfull one or the | |
| * first build if there is not such build | |
| * | |
| * @param build the current build | |
| */ | |
| def listOfFailedBuilds(build) { | |
| def results = [] | |
| while (build != null && build.result != 'SUCCESS') { | |
| println("Found unsuccessfull build ${build.number}") | |
| results.add(build) | |
| build = build.getPreviousBuild() | |
| } | |
| if (build != null) { | |
| println("Found successfull build ${build.number}") | |
| results.add(build) | |
| } else { | |
| println("Found EOL") | |
| } | |
| results | |
| } | |
| @NonCPS | |
| def getChangeString(passedBuilds) { | |
| def changeString = "" | |
| echo "Gathering Changes Since Last Successful Build" | |
| for (int x = 0; x < passedBuilds.size(); x++) { | |
| def currentBuild = passedBuilds[x]; | |
| def buildNumber = currentBuild.number | |
| echo "Changes for Build ${buildNumber}" | |
| def changeLogSets = currentBuild.rawBuild.changeSets | |
| for (int i = 0; i < changeLogSets.size(); i++) { | |
| def entries = changeLogSets[i].items | |
| for (int j = 0; j < entries.length; j++) { | |
| def entry = entries[j] | |
| changeString += "* ${entry.msg} by ${entry.author} \n" | |
| } | |
| } | |
| } | |
| if (!changeString) { | |
| changeString = " - No new changes" | |
| } | |
| echo changeString | |
| return changeString; | |
| } | |
| @NonCPS | |
| def getIssueList(){ | |
| def list = [] | |
| def changes = getChangeString(passedBuilds) | |
| def re = /IB2-([0-9])*/ | |
| def y = changes =~ re | |
| while (y){ | |
| list.add(y.group().toString()) | |
| } | |
| if (list.size() > 0) { | |
| echo 'Detected JIRA tickets' | |
| echo list.toString() | |
| } else { | |
| echo 'No JIRA tickets detected' | |
| } | |
| return list | |
| } |