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
• 180 points
1,175 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
+2 votes
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
• 78,020 points
848 views
0 votes
1 answer
0 votes
1 answer

What is the use of using declarative pipeline (i.e jenkins file) over scripted pipeline in real time

Hi@Shashi, The declarative pipeline is a relatively new ...READ MORE

answered Oct 28 in Jenkins by MD
• 78,020 points
83 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,870 points
896 views
+15 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,450 points
804 views
+2 votes
1 answer