1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/src/com/sap/piper/JenkinsUtils.groovy
Oliver Nocon e11478ca00
cloudFoundryDeploy - add deployment reporting to Influx (#421)
Add reporting of operations-related data to Influx (if configured), like:
* Version of deployed artifact
* Deployment time
* Target infrastructure for deployment
2019-01-18 08:25:22 +01:00

50 lines
1.2 KiB
Groovy

package com.sap.piper
import com.cloudbees.groovy.cps.NonCPS
import jenkins.model.Jenkins
import org.jenkinsci.plugins.workflow.steps.MissingContextVariableException
@NonCPS
static def isPluginActive(pluginId) {
return Jenkins.instance.pluginManager.plugins.find { p -> p.isActive() && p.getShortName() == pluginId }
}
def nodeAvailable() {
try {
sh "echo 'Node is available!'"
} catch (MissingContextVariableException e) {
echo "No node context available."
return false
}
return true
}
@NonCPS
def getCurrentBuildInstance() {
return currentBuild
}
@NonCPS
def getRawBuild() {
return getCurrentBuildInstance().rawBuild
}
def isJobStartedByTimer() {
return isJobStartedByCause(hudson.triggers.TimerTrigger.TimerTriggerCause.class)
}
def isJobStartedByUser() {
return isJobStartedByCause(hudson.model.Cause.UserIdCause.class)
}
@NonCPS
def isJobStartedByCause(Class cause) {
def startedByGivenCause = false
def detectedCause = getRawBuild().getCause(cause)
if (null != detectedCause) {
startedByGivenCause = true
echo "Found build cause ${detectedCause}"
}
return startedByGivenCause
}