I've seen this example on how to load declarative piplines form a shared Library: https://jenkins.io/doc/book/pipeline/shared-libraries/#defining-declarative-pipelines
But I would like to have the pipeline as inline functions:
def linux_platform = "U1604_x64_gcc54"
def windows_platform = "WIN10_x64_vc141"
properties(
[
parameters(
[
choice(name: 'platform', choices: [linux_platform, windows_platform], description: 'Platform'),
string(defaultValue: "-1", description: 'Upsteam Project build number', name: 'upsteam_project_build_number')
]
)
]
)
if(params.platform == windows_platform) {
windows(params.upsteam_project_build_number)
}
def windows(upsteam_project_build_number) {
pipeline {
agent {
label windows_platform
}
environment {
WINDOWS_ENV = "C:/my_path"
}
stages {
stage('Do stuff') {
steps{
echo "Doing stuff"
}
}
}
post {
failure {
job_status_mail(currentBuild.currentResult, JOB_NAME, BUILD_NUMBER, BUILD_URL)
}
fixed {
job_status_mail("fixed", JOB_NAME, BUILD_NUMBER, BUILD_URL)
}
}
}
}
Im getting the following error:
java.lang.NoSuchMethodError: No such DSL method 'agent' found among steps
Is my syntax some how wrong or is it not possible to load a pipeline from a inlne function?
I'm running:
- Jenkins ver. 2.138.4
- Declarative Pipeline Plugin ver. 1.3.8