forked from rstudio/rstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.macos
169 lines (127 loc) · 6.44 KB
/
Jenkinsfile.macos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
pipeline {
agent { label 'macos-v1.4-arm64' }
options {
timestamps()
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '100'))
}
parameters {
string(name: 'RSTUDIO_VERSION_MAJOR', defaultValue: '1', description: 'RStudio Major Version')
string(name: 'RSTUDIO_VERSION_MINOR', defaultValue: '1', description: 'RStudio Minor Version')
string(name: 'RSTUDIO_VERSION_PATCH', defaultValue: '999', description: 'RStudio Patch Version')
string(name: 'RSTUDIO_VERSION_SUFFIX', defaultValue: '+9999', description: 'RStudio Pro Suffix Version')
string(name: 'GIT_REVISION', defaultValue: 'main', description: 'Git revision to build')
string(name: 'BRANCH_NAME', defaultValue: 'origin/main', description: 'Branch name to build')
string(name: 'SLACK_CHANNEL', defaultValue: '#ide-builds', description: 'Slack channel to publish build message.')
}
environment {
PATH = "$HOME/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PACKAGE_OS = 'macOS'
}
stages {
stage('dependencies') {
environment {
// boost won't compile without the brew version of openssl.
// only add it to the dep resolve step though, or the ide build will compile against the wrong openssl
PATH = '/usr/local/opt/openssl/bin:/usr/local/opt/openssl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
}
steps {
withCredentials([usernameColonPassword(credentialsId: 'github-rstudio-jenkins', variable: "GITHUB_LOGIN")]) {
sh 'cd dependencies/osx && RSTUDIO_GITHUB_LOGIN=$GITHUB_LOGIN ./install-dependencies-osx && cd ../..'
}
}
}
stage('build') {
steps {
script {
// unlock keychain to ensure build gets signed.
withCredentials([string(credentialsId: 'ide-keychain-passphrase', variable: 'KEYCHAIN_PASSPHRASE')]){
sh 'security unlock-keychain -p $KEYCHAIN_PASSPHRASE && security set-keychain-settings' // turn off timeout
}
// set requisite environment variables
def env = "RSTUDIO_VERSION_MAJOR=${params.RSTUDIO_VERSION_MAJOR} RSTUDIO_VERSION_MINOR=${params.RSTUDIO_VERSION_MINOR} RSTUDIO_VERSION_PATCH=${params.RSTUDIO_VERSION_PATCH} RSTUDIO_VERSION_SUFFIX=${params.RSTUDIO_VERSION_SUFFIX}"
// build rstudio
sh 'cd package/osx && ${env} ./make-package clean && cd ../..'
}
}
}
stage('tests') {
environment {
PATH = "${env.HOME}/opt/bin:${env.PATH}"
}
steps {
script {
try {
// attempt to run cpp unit tests
// problems with rsession finding openssl, so those tests
// are disabled until we solve it (#6890)
sh "cd package/osx/build/src/cpp && ./rstudio-tests"
} catch(err) {
currentBuild.result = "UNSTABLE"
}
}
}
}
stage('notarize and upload') {
environment {
PATH = "${env.HOME}/opt/bin:${env.PATH}"
}
steps {
script {
// extract name of package to publish
def packageFile = sh (
script: "basename `ls package/osx/build/RStudio-*.dmg`",
returnStdout: true
).trim()
def buildType = sh (
script: "cat version/BUILDTYPE",
returnStdout: true
).trim().toLowerCase()
def buildDest = "s3://rstudio-ide-build/desktop/macos/"
withCredentials([usernamePassword(credentialsId: 'ide-apple-notarizer', usernameVariable: 'APPLE_ID', passwordVariable: 'APPLE_ID_PASSWORD')]) {
sh "docker/jenkins/notarize-release.sh package/osx/build/${packageFile}"
}
// this job is going to run on a macOS slave, which cannot use an instance-profile
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'jenkins-aws']]) {
sh "aws s3 cp package/osx/build/${packageFile} ${buildDest}"
}
// upload daily build redirects
withCredentials([file(credentialsId: 'www-rstudio-org-pem', variable: 'wwwRstudioOrgPem')]) {
sh "docker/jenkins/publish-daily-binary.sh https://s3.amazonaws.com/rstudio-ide-build/desktop/macos/${packageFile} ${wwwRstudioOrgPem}"
}
// upload debug symbols to Sentry
withCredentials([string(credentialsId: 'ide-sentry-api-key', variable: 'SENTRY_API_KEY')]){
// construct release version
def RSTUDIO_RELEASE = "${params.RSTUDIO_VERSION_MAJOR}.${params.RSTUDIO_VERSION_MINOR}.${params.RSTUDIO_VERSION_PATCH}${params.RSTUDIO_VERSION_SUFFIX}"
// create new release on Sentry
sh "sentry-cli --auth-token ${SENTRY_API_KEY} releases --org rstudio --project ide-backend new ${RSTUDIO_RELEASE}"
// upload Javascript source maps
sh "cd package/osx/build/gwt && sentry-cli --auth-token ${SENTRY_API_KEY} releases --org rstudio --project ide-backend files ${RSTUDIO_RELEASE} upload-sourcemaps --ext js --ext symbolMap --rewrite ."
// associate commits
sh "sentry-cli --auth-token ${SENTRY_API_KEY} releases --org rstudio --project ide-backend set-commits --auto ${RSTUDIO_RELEASE}"
// finalize release
sh "sentry-cli --auth-token ${SENTRY_API_KEY} releases --org rstudio --project ide-backend finalize ${RSTUDIO_RELEASE}"
// upload C++ debug information
sh "cd package/osx/build/src/cpp && sentry-cli --auth-token ${SENTRY_API_KEY} upload-dif --org rstudio --project ide-backend -t dsym ."
}
// publish build to dailies page
withCredentials([usernamePassword(credentialsId: 'github-rstudio-jenkins', usernameVariable: 'GITHUB_USERNAME', passwordVariable: 'GITHUB_PAT')]) {
// derive product
def product="desktop"
if (params.RSTUDIO_VERSION_SUFFIX.contains("pro")) {
product = "desktop-pro"
}
// publish the build
sh "docker/jenkins/publish-build.sh --build ${product}/macos --url https://s3.amazonaws.com/rstudio-ide-build/desktop/macos/${packageFile} --pat ${GITHUB_PAT} --file package/osx/build/${packageFile} --version ${params.RSTUDIO_VERSION_MAJOR}.${params.RSTUDIO_VERSION_MINOR}.${params.RSTUDIO_VERSION_PATCH}${params.RSTUDIO_VERSION_SUFFIX}"
}
}
}
}
}
post {
always {
deleteDir()
sendNotifications slack_channel: SLACK_CHANNEL
}
}
}