Skip to content

Instantly share code, notes, and snippets.

View stephenmenton's full-sized avatar

Stephen Menton stephenmenton

View GitHub Profile
@stephenmenton
stephenmenton / rmMultibranchScanTrigger.groovy
Last active May 22, 2019 20:29
need to remove triggers from multibranch pipeline jobs
def job = Jenkins.instance.getItemByFullName('/path/to/multibranchPipeline')
job.triggers.forEach { k, v ->
println "k: ${k}"
println "v: ${v}"
if (k instanceof com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger$DescriptorImpl) {
println "match, removing"
job.triggers.remove(k)
}
}
job.save()

Keybase proof

I hereby claim:

  • I am stephenmenton on github.
  • I am aquaone (https://keybase.io/aquaone) on keybase.
  • I have a public key ASC3iEPGTlNqmLKOX006YKuKPvnLnGFxoMzBEwMqn6ltJwo

To claim this, I am signing this object:

@stephenmenton
stephenmenton / newToken.groovy
Last active January 29, 2019 23:22
"upsert" api token, print the value
String userName = 'namehere'
String tokenName = 'namehere'
User user = User.get(userName)
ApiTokenProperty tokenProperty = user.getProperty(ApiTokenProperty.class)
tokenStore = tokenProperty.tokenStore
tokenStore.deleteAllLegacyTokens() // unneeded later
tokenStore.tokenList.removeAll { it.name == tokenName }
newToken = tokenStore.generateNewToken(tokenName)
println newToken.plainValue
@stephenmenton
stephenmenton / currentBuild.result not updating
Last active September 23, 2020 19:33
scripted pipeline not updating build result
Jenkins in scripted pipeline is not updating currentBuild.result or currentBuild.currentResult on failure
currentBuild.result is null
currentBuild.getResult() is null
currentBuild.currentResult is 'SUCCESS'
currentBuild.rawBuild.result is null
currentBuild.rawBuild.getResult() is null
must explicitly set result