Jenkins声明式流水线调用rtServer报错:未找到该DSL方法
Hey there, let's get this sorted out—this error usually boils down to a missing plugin or a tiny syntax mistake in your pipeline code. Here's what you need to do:
1. Make Sure the JFrog Artifactory Plugin is Installed
The rtServer DSL method is provided exclusively by the JFrog Artifactory Plugin for Jenkins. If this plugin isn't installed, Jenkins has no clue what rtServer is supposed to do.
- Head over to your Jenkins dashboard, navigate to Manage Jenkins > Plugins.
- Search for "JFrog Artifactory" in the Available plugins tab (or check the Installed tab to confirm it's already there).
- Install the plugin if it's missing, then restart Jenkins to activate it fully.
2. Fix the Syntax Error in Your rtServer Step
Looking at your code, there's a small but critical mistake in the timeout parameter—you used an equals sign (=) instead of a colon (:). In Groovy (which Jenkins pipelines rely on), key-value parameters for method calls require colons, not equals signs.
Here's the corrected code snippet:
// ... 前置阶段 stage('rtServer to Artifactory') { steps { rtServer ( id: 'Artifactory-MC', url: 'http://my-artifactory-domain/artifactory', credentialsId: 'credentialsID', timeout: 100 // 这里把=改成: ) } } // ... rtUpload阶段及post块
3. Verify Plugin Compatibility (If Issues Persist)
If you still hit the error after installing the plugin and fixing the syntax, double-check that your Artifactory plugin version is compatible with your Jenkins version. Older plugin versions might not support the rtServer DSL in declarative pipelines, so try updating to the latest stable version of the plugin that works with your Jenkins instance.
Also, make sure your rtUpload step references the correct id you defined in rtServer (e.g., adding serverId: 'Artifactory-MC' to the rtUpload configuration) to ensure the upload uses the Artifactory server you configured.
内容的提问来源于stack exchange,提问作者Ayman Arif

