Hello,

I'm feeling stuck at the moment trying to sort this out. Hopefully ya'll 
are able to assist.

Situation:

We are converting a traditional Freestyle project to Pipeline. The 
Freestyle project has build parameters that the user kicking off the build 
can edit for their needs. I'm trying to figure out how to manage this Build 
Parameters in the Pipeline world. 

Here is what I'm currently implementing:

I have a Key/Value Properties file saved and stored in AWS S3. The format 
of this file is based off of the EnvInject 
requirements: https://en.wikipedia.org/wiki/.properties

*  CLIENT_ID=ClientShortName*
*  LPRLISTENPORT=7201*

In my first Stage, I am fetching this file using the AWS CLI from S3. 
(While I'm troubleshooting, I *cat* this file to ensure the download was 
successful and content is present.)
After the file has been downloaded, I am attempting to use the *properties* 
command 
in the Jenkinsfile to load the file (the filename is stored in a variable 
for flexibility:

*  def deployParams = 'deploy.properties' // testing*
*  properties([*
*    [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', 
artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', 
numToKeepStr: '3']],*
*    [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: 
false], [$class: 'ThrottleJobProperty', categories: [], 
limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 0, 
maxConcurrentTotal: 0, paramsToUseForLimit: '', throttleEnabled: false, 
throttleOption: 'project'],*
*    [$class: 'EnvInjectJobProperty', info: [loadFilesFromMaster: false, 
propertiesFilePath: "${deployParams}"], keepBuildVariables: true, 
keepJenkinsSystemVariables: true, on: true]*
*  ])*

The second Stage contains the code checkout. I was previously using the 
*Git* plugin, but I saw in the EnvInject Plugin that the properties aren't 
loaded until after the SCM checkout (I assume the *git* function satisfies 
this, but I'm not 100%). 
After the checkout, I am performing some simple validation to see if the 
loaded properties are available as Environment Variables as I expect.

*  checkout scm*
*  envVars = env.getEnvironment()*
*  echo "${env.getEnvironment()}"*
*  println envVars.containsKey("LPRLISTENPORT")*
*  println envVars.containsKey("CLIENT_ID")*

The Console Ouput from the Pipeline execution is below. A lot has been 
scrubbed for privacy, but here are the main points. Please let me know if 
further info is needed:

[Pipeline] properties

[Pipeline] stage (code checkout)

Entering stage code checkout
Proceeding

[Pipeline] echo[BUILD_DISPLAY_NAME:#113, BUILD_ID:113, BUILD_NUMBER:113, 
BUILD_TAG:jenkins-pipeline-113, BUILD_URL:https:///113/, CLASSPATH:, 
HUDSON_HOME:/var/lib/jenkins, HUDSON_SERVER_COOKIE:c719bc37b08d7ba9, 
HUDSON_URL:https://jenkins/, JENKINS_HOME:/var/lib/jenkins, 
JENKINS_SERVER_COOKIE:c719bc37b08d7ba9, JENKINS_URL:https://jenkins/, 
JOB_NAME:pipeline, JOB_URL:https://pipeline/][Pipeline] echofalse[Pipeline] 
echofalse


Any help or insight is greatly appreciated.


-Brendan

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f6d60d49-8e20-4cdc-a13e-6c7cec062247%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to