I have a shared library repo with this structure:
(root)
+- src
| +- com
| +- company
| +- DeploySteps.groovy
+- vars
| +- MainDeploySteps.groovy
This library importing to job via Jenkinsfile as follows:
library identifier: 'jenkinslib@master', retriever: modernSCM(
[$class : 'GitSCMSource',
remote : '[email protected]:jenkinslib.git',
credentialsId: 'jenkins-credentials'])
Class in repo in src/com/company/DeploySteps.groovy has a method (for example CheckoutSCM) which I want include in Jenkinsfile.
DeploySteps.groovy:
def CheckoutSCM() {
useful steps here
}
Is there a possible include this particular method in Jenkinsfile like
import com.company.DeploySteps
And then use it like:
CheckoutSCM('repo-here')
In Jenkinsfile later? I read documentation many times but no found answer is there possible import something from src
folder, not only from vars
.
Why I am asking because now when import: import com.company.DeployUtils
and then try invoke method CheckoutSCM()
see the error in Jenkins console output:
java.lang.NoSuchMethodError: No such DSL method 'CheckoutSCM' found among steps
with list of available methods below, where no mine CheckoutSCM
for sure)
So, is there possible import class from src
folder to Jenkinsfile?
P.S. I can access in Jenkinsfile MainDeploySteps as
MainDeploySteps {}
with no problems however.
Jenkinsfile
. – Kish