Unable to readfilePropertie in Jenkins Declerative Pipeline. I want to read properties from ini file in workspace.

0 votes

I am using jenkins declerative pipeline to read file properties from workspace , File is in INI format (ansible host file).

I am using following syntax but its not working throwing following error, Please suggest how to read or correct syntax to read the properties.

Groovy code:

def props  = readProperties file: 'files/hosts'
assert props['webserver']
or 
println props['webserver']
------------------------------------
hosts files contains following:
-------------------------------
[webserver]
server1
server2
[dbserver]
db1
db2

I want to read value of webserver 1 like webserver[0]...

Error which i am getting:

java.lang.NoSuchMethodError: No such DSL method 'readProperties' found among steps [ArtifactoryGradleBuild, MavenDescriptorStep, addBadge, addErrorBadge, addHtmlBadge, addInfoBadge, addInteractivePromotion, addShortText, addWarningBadge, ansiColor, ansiblePlaybook, ansibleVault, archive, artifactoryDistributeBuild, artifactoryDownload, artifactoryEditProps, artifactoryMavenBuild, artifactoryNpmInstall, artifactoryNpmPublish, artifactoryPromoteBuild, artifactoryUpload, bat, build, catchError, checkout, collectEnv, conanAddRemote, conanAddUser,  
Mar 27 in Jenkins by Atul
• 150 points
230 views
Do you have the needed plugins installed in Jenkins? Are you using maven as the build tool?
not using maven, I need to read file properties for same condition. Which throwing above error. By the way to use file properties we need Pipeline Step Utility plugin or something else?

For using the def props syntax that you have used, you will need to have a pipeline utility steps plugin.

Do check this out https://github.com/jenkinsci/pipeline-utility-steps-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/pipeline/utility/steps/conf/ReadPropertiesStep/help.html#L69

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Jenkins

0 votes
2 answers
+1 vote
1 answer

Want to Invoke Other Jenkins Job from Declerative pipleline || Not working

Hi@atul, As it is showing in your error ...READ MORE

answered Apr 8 in Jenkins by MD
• 22,520 points
125 views
0 votes
1 answer

unable to compile java code in Jenkins

If the code is compiling and running ...READ MORE

answered Apr 25, 2018 in Jenkins by DareDev
• 6,850 points
612 views
+2 votes
5 answers
+1 vote
5 answers

Unable to login to Jenkins even if I enter valid credentials.

Disable security by editing these two classes ...READ MORE

answered Apr 26, 2019 in Jenkins by Vedant
10,654 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,400 points
492 views
0 votes
1 answer