Skip to content

Instantly share code, notes, and snippets.

@dongmai
Created January 5, 2022 10:05
Show Gist options
  • Save dongmai/e641249e19cf9a8f44989a2940ca3424 to your computer and use it in GitHub Desktop.
Save dongmai/e641249e19cf9a8f44989a2940ca3424 to your computer and use it in GitHub Desktop.
Copy a jenkins job
let jenkins = JenkinsService.initJenkinsApi(jenkin)
jenkins.copy_job(
templateJobName,
jobName,
(config) => {
config = config.replace('<concurrentBuild>false</concurrentBuild>', `<concurrentBuild>false</concurrentBuild>\n<customWorkspace>workspace/${templateJobName}</customWorkspace>`)
config = config.replace('{GYM_EXPORT_TEAM_ID}', `${appStoreAccount.teamId}`)
config = config.replace('{KEY_ID}', `${appStoreAccount.keyId}`)
config = config.replace('{ISSUER_ID}', `${appStoreAccount.issuerId}`)
config = config.replace('{KEY_CONTENT_BASE64}', `${Util.base64Text(appStoreAccount.apiKey)}`)
config = config.replace('{REMOTE_JOB_ID}', jenkinJob.id)
config = config.replace('{KEYCHAIN_PASSWORD}', jenkin.keychainPassword)
config = config.replace('{APP_GENERATION_ENDPOINT}', endpointUrl)
return config
},
{},
(err, data) => {
if (err) {
reject(err)
} else {
data.jobName = jobName
resolve(data)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment