Re: Jenkins Pipeline: Variable expansion issues

2019-03-12 Thread Mike Craig
Good thinking, I'll try to do a strip on them and see if that clears it up.

On Tuesday, March 12, 2019 at 7:18:14 AM UTC-7, Reinhold Füreder wrote:
>
> Hi Mike,
>
>  
>
> it looks like the variables are actually strings with a line break at the 
> end, and not integers?
>
>  
>
> HTH Reinhold
>
>  
>
> *From:* jenkins...@googlegroups.com  <
> jenkins...@googlegroups.com > *On Behalf Of *Mike Craig
> *Sent:* Montag, 11. März 2019 23:33
> *To:* Jenkins Users >
> *Subject:* Jenkins Pipeline: Variable expansion issues
>
>  
>
> Hello,
>
>  
>
> The following snippet from my pipeline is acting very strangely, the 
> values from the print statements are correct
>
>  
>
>   print "asgName: $asgName"
>
>  print "asgMax: $asgMax"
>
>  print "asgMin: $asgMin"
>
>  asgIncrease = (asgMax * 2)
>
>  print "Setting ASG size to ${asgIncrease}"
>
>  sh ("aws autoscaling update-auto-scaling-group --min-size ${
> asgMin} --max-size ${asgMax} --region ${region} --auto-scaling-group-name 
> ${asgName} ")
>
>  
>
> output
>
>  
>
> *15:27:13*  ecs_service_name: lab-us-west-2-lab-rat
>
> [Pipeline] sh
>
> *15:27:14*  + aws autoscaling describe-auto-scaling-groups --region us-west-2
>
> *15:27:14*  + jq .AutoScalingGroupName
>
> *15:27:14*  + jq '.AutoScalingGroups[]'
>
> *15:27:14*  + jq 'select (.AutoScalingGroupName | contains 
> ("lab-us-west-2-lab-rat"))'
>
> [Pipeline] sh
>
> *15:27:18*  + aws autoscaling describe-auto-scaling-groups --region us-west-2
>
> *15:27:18*  + jq 'select (.AutoScalingGroupName | contains 
> ("lab-us-west-2-lab-rat"))'
>
> *15:27:18*  + jq .MaxSize
>
> *15:27:18*  + jq '.AutoScalingGroups[]'
>
> [Pipeline] sh
>
> *15:27:22*  + jq 'select (.AutoScalingGroupName | contains 
> ("lab-us-west-2-lab-rat"))'
>
> *15:27:22*  + jq .MinSize
>
> *15:27:22*  + jq '.AutoScalingGroups[]'
>
> *15:27:22*  + aws autoscaling describe-auto-scaling-groups --region us-west-2
>
> [Pipeline] echo
>
> *15:27:26*  asgName: "lab-us-west-2-lab-rat-serviceInstanceAutoscalingGroup"
>
> *15:27:26*  
>
> [Pipeline] echo
>
> *15:27:26*  asgMax: 1
>
> *15:27:26*  
>
> [Pipeline] echo
>
> *15:27:26*  asgMin: 1
>
> *15:27:26*  
>
> [Pipeline] echo
>
> *15:27:26*  Setting ASG size to 1
>
> *15:27:26*  1
>
> *15:27:26*  
>
> [Pipeline] sh
>
> *15:27:26*  + aws autoscaling update-auto-scaling-group --min-size 1
>
> *15:27:27*  usage: aws [options]   [ ...] 
> [parameters]
>
> *15:27:27*  To see help text, you can run:
>
> *15:27:27*  
>
> *15:27:27*aws help
>
> *15:27:27*aws  help
>
> *15:27:27*aws   help
>
> *15:27:27*  aws: error: argument --auto-scaling-group-name is required
>
>  
>
> *2 things here, *
>
> 1. the asgIncrease variable should evaluate to 2, as I'm doubling the 
> original variable.  
>
> 2 The line where the "aws autoscaling" command is executed does not expand 
> and execute the entire line. I have tried hardcoding values here, and that 
> seems to work, but how to use variables??
>
>  
>
>  
>
> What am I doing wrong?
>
>  
>
> Thank you!
>
>  
>
>  
>
>  
>
>  
>
> -- 
> 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 jenkinsci-use...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/f6560954-54e3-4afd-a8cf-f76bd9de11c8%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/f6560954-54e3-4afd-a8cf-f76bd9de11c8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b4e1a11d-c488-49af-9bd0-0cffb6c7f68d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Jenkins Pipeline: Variable expansion issues

2019-03-11 Thread Mike Craig
Hello,

The following snippet from my pipeline is acting very strangely, the values 
from the print statements are correct

  print "asgName: $asgName"
 print "asgMax: $asgMax"
 print "asgMin: $asgMin"
 asgIncrease = (asgMax * 2)
 print "Setting ASG size to ${asgIncrease}"
 sh ("aws autoscaling update-auto-scaling-group --min-size ${
asgMin} --max-size ${asgMax} --region ${region} --auto-scaling-group-name ${
asgName} ")


output

*15:27:13*  ecs_service_name: lab-us-west-2-lab-rat[Pipeline] sh 
*15:27:14*
  + aws autoscaling describe-auto-scaling-groups --region us-west-2*15:27:14*  
+ jq .AutoScalingGroupName*15:27:14*  + jq '.AutoScalingGroups[]'*15:27:14*  + 
jq 'select (.AutoScalingGroupName | contains ("lab-us-west-2-lab-rat"))'
>
> [Pipeline] sh 
> *15:27:18*
>   + aws autoscaling describe-auto-scaling-groups --region us-west-2*15:27:18* 
>  + jq 'select (.AutoScalingGroupName | contains 
> ("lab-us-west-2-lab-rat"))'*15:27:18*  + jq .MaxSize*15:27:18*  + jq 
> '.AutoScalingGroups[]'
>
> [Pipeline] sh 
> 
>
> *15:27:22*  + jq 'select (.AutoScalingGroupName | contains 
> ("lab-us-west-2-lab-rat"))'*15:27:22*  + jq .MinSize*15:27:22*  + jq 
> '.AutoScalingGroups[]'*15:27:22*  + aws autoscaling 
> describe-auto-scaling-groups --region us-west-2
>
> [Pipeline] echo 
> *15:27:26*
>   asgName: "lab-us-west-2-lab-rat-serviceInstanceAutoscalingGroup"*15:27:26*  
> [Pipeline] echo 
> *15:27:26*
>   asgMax: 1*15:27:26*  [Pipeline] echo 
> *15:27:26*
>   asgMin: 1*15:27:26*  [Pipeline] echo 
> *15:27:26*
>   Setting ASG size to 1*15:27:26*  1*15:27:26*  [Pipeline] sh 
> *15:27:26*
>   + aws autoscaling update-auto-scaling-group --min-size 1
>
> *15:27:27*  usage: aws [options]   [ ...] 
> [parameters]*15:27:27*  To see help text, you can run:*15:27:27*  *15:27:27*  
>   aws help*15:27:27*aws  help*15:27:27*aws  
>  help*15:27:27*  aws: error: argument --auto-scaling-group-name 
> is required
>
>
*2 things here, *
1. the asgIncrease variable should evaluate to 2, as I'm doubling the 
original variable.  
2 The line where the "aws autoscaling" command is executed does not expand 
and execute the entire line. I have tried hardcoding values here, and that 
seems to work, but how to use variables??


What am I doing wrong?

Thank you!



 

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f6560954-54e3-4afd-a8cf-f76bd9de11c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is there a trim method in the string parameter ?

2019-03-06 Thread Mike Craig
Hello,

For clear text data entry I'd like to be able to enable a 'trim' feature.

This page doesn't document one:
https://jenkins.io/doc/book/pipeline/syntax/#parameters

I would like something like this, does it exist? I couldn't get the below 
to work for me.
parameters {
   string(name: 'component', trim:true, description: 'component name for 
terraform')
  }

Thank you,

Mike

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/28cb5f4a-7209-4c43-855b-2c9b38539eb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pipeline: How to modify Build History status monitor

2019-02-28 Thread Mike Craig
Thank you!

On Thu, Feb 28, 2019 at 9:48 AM Simon Bayer  wrote:

> Hi Mike, u could use the object 'currentbuild' to modify the job
> description. Its available in declarative pipeline builds (e.g. with
> multiproject pipeline plugin). Furthermore the build status can be set. But
> beware: if u set the status to 'failure', Post build actions for failures
> will not be triggered. Use the default step 'error' instead.
>
> Script-Example:
> script {
> currentBuild.description = 'Jenkins is awesome'
> currentBuild.status = 'success'
> }
>
> Greets
>
>
>
>  Ursprüngliche Nachricht 
> Von: Mike Craig 
> Datum: 27.02.19 23:12 (GMT+01:00)
> An: Jenkins Users 
> Betreff: Pipeline: How to modify Build History status monitor
>
> Hello,
>
> Prior to using declarative pipeline, we were able to modify the Build
> History to indicate information we wanted to see.
> We are using a shared "terraform-deploy" pipeline now and would like to
> modify this build history to display which project (aka component) was
> built in that run.
>
> [image: build history.png]
>
> Thank you,
>
> Mike
>
> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/c7a6018e-3600-42f7-91c5-56caeae99bdc%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/c7a6018e-3600-42f7-91c5-56caeae99bdc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/GY9ouPE496U/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/BN8PR15MB3441DF5E5735C011915B8C2BAC750%40BN8PR15MB3441.namprd15.prod.outlook.com
> <https://groups.google.com/d/msgid/jenkinsci-users/BN8PR15MB3441DF5E5735C011915B8C2BAC750%40BN8PR15MB3441.namprd15.prod.outlook.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAEmhiT8N1a3mDG2ZQX8B%2BexpCCE41V_SpCb9C99aw9pK0QooBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pipeline: How to modify Build History status monitor

2019-02-28 Thread Mike Craig
Perfect, thank you for the reference! Having a "how-to" question, and
mapping that to a documentation section is the hardest part for me. :)

On Wed, Feb 27, 2019 at 10:55 PM Andreas Magnusson <
andreas.ch.magnus...@gmail.com> wrote:

> Not quite sure what you want to do, but we modify currentBuild.displayName
> and currentBuild.description from within our pipeline.
> They are documented under Pipeline Syntax | Global Variable Reference
>
> /Andreas
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/GY9ouPE496U/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/bbf0bdca-3bd6-4e4d-a163-7e282fa25336%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAEmhiT_oNe5EgZdEdKshof0hGVhQCEVY_toocGT%3D5AOrgsCY%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Pipeline: How to modify Build History status monitor

2019-02-27 Thread Mike Craig
Hello,

Prior to using declarative pipeline, we were able to modify the Build 
History to indicate information we wanted to see.
We are using a shared "terraform-deploy" pipeline now and would like to 
modify this build history to display which project (aka component) was 
built in that run.

[image: build history.png]

Thank you,

Mike

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c7a6018e-3600-42f7-91c5-56caeae99bdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to copy existing 'template' job to create new build job

2014-07-16 Thread Mike Craig
For anyone interested, I followed my intuition and change the command that 
writes the config file back out to force UTF8 encoding. This fixed it. 
The updated file is attached.




On Tuesday, July 15, 2014 11:43:20 AM UTC-7, Mike Craig wrote:
>
> Hello,
>  
> I have previously used the Jenkins CLI to create a new job from a 
> template. However, (known issue) I am unable to copy Promoted Builds steps 
> as part of this. So I have gone down the path of trying to robocopy the 
> template job to a new job name, and search/replace values within. For some 
> reason Jenkins is not picking up the new job.
>  
> Here are the basic steps my script is executing
>
>1. Robocopy "\\$JenkinsServer\jobs\$TemplateJob" "
>\\$JenkinsServer\jobs\$NewBuildJobName" *.* /E /XD .git /XF *.log
>2. Then using Powershell: replace "##RELEASEVERSION##" flag with my 
>new release version (ie. v17)
>3. Then using Powershell: replace "true" with 
>"false"
>4. Then write the xml file back out to "
>\\$JenkinsServer\jobs\$NewBuildJobName\config.xml"
>5. I then look "\\$JenkinsServer\jobs\$jobname\promotions" and iterate 
>through each promotion level
>6. I replace "$templateJobName" with 
>"$jobname"
>7. I then try to use the CLI to reload-configuration (which doesn't 
>work for me, so I do it manually in the UI)
>   1. Doesn't work: java -jar ..\bin\jenkins-cli.jar -s "
>   http://$JenkinsServer/"; reload-configuration  --username $UserName 
>   --password $Password
>
>  
> Once I reload configuration, Jenkins does not see and pick up the new 
> build. I have not been able to find any other config files where build jobs 
> are stored/configuration apart from the jobs folder.
>  
> One thing I have noticed through a folder compare with BeyondCompare, is 
> that the new files are Unicode, and not UTF-8, could have be causing my 
> Jenkins issues?
>  
> For fun, I have attached my script, if you have any feedback/suggestions 
> I'm all ears.
>  
> Assumptions: 
>
> A couple functions in the script take a parameter $JenkinsServer, which 
> defaults to localhost, you will need to update as per your environment.
>
> Set these values as per your needs
> $ReleaseVersion = "v1.0"
> $ProjectToBuild = "MyNewProject"
>
> You have a 'template' job created in the naming format of 
> "template-JobName"
> You run Powershell as an Admin
>
>  
> Thank you.
>  
> Mike
>  
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Functions_JenkinsAutomation.ps1
Description: Binary data


How to copy existing 'template' job to create new build job

2014-07-15 Thread Mike Craig
Hello,
 
I have previously used the Jenkins CLI to create a new job from a template. 
However, (known issue) I am unable to copy Promoted Builds steps as part of 
this. So I have gone down the path of trying to robocopy the template job 
to a new job name, and search/replace values within. For some reason 
Jenkins is not picking up the new job.
 
Here are the basic steps my script is executing

   1. Robocopy "\\$JenkinsServer\jobs\$TemplateJob" "
   \\$JenkinsServer\jobs\$NewBuildJobName" *.* /E /XD .git /XF *.log
   2. Then using Powershell: replace "##RELEASEVERSION##" flag with my new 
   release version (ie. v17)
   3. Then using Powershell: replace "true" with 
   "false"
   4. Then write the xml file back out to "
   \\$JenkinsServer\jobs\$NewBuildJobName\config.xml"
   5. I then look "\\$JenkinsServer\jobs\$jobname\promotions" and iterate 
   through each promotion level
   6. I replace "$templateJobName" with 
   "$jobname"
   7. I then try to use the CLI to reload-configuration (which doesn't work 
   for me, so I do it manually in the UI)
  1. Doesn't work: java -jar ..\bin\jenkins-cli.jar -s "
  http://$JenkinsServer/"; reload-configuration  --username $UserName 
  --password $Password
   
 
Once I reload configuration, Jenkins does not see and pick up the new 
build. I have not been able to find any other config files where build jobs 
are stored/configuration apart from the jobs folder.
 
One thing I have noticed through a folder compare with BeyondCompare, is 
that the new files are Unicode, and not UTF-8, could have be causing my 
Jenkins issues?
 
For fun, I have attached my script, if you have any feedback/suggestions 
I'm all ears.
 
Assumptions: 

A couple functions in the script take a parameter $JenkinsServer, which 
defaults to localhost, you will need to update as per your environment.

Set these values as per your needs
$ReleaseVersion = "v1.0"
$ProjectToBuild = "MyNewProject"

You have a 'template' job created in the naming format of "template-JobName"
You run Powershell as an Admin

 
Thank you.
 
Mike
 

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Functions_JenkinsAutomation2.ps1
Description: Binary data


Createing job through CLI

2014-07-02 Thread Mike Craig
Hello,

I am using the Jenkins CLI to pull down a list of 'template' jobs, search
and replace for our release version, then "create" a job using the job XML
which I have pulled from Jenkins.

The template job uses "promoted builds" plugin to have CI, "Directed
Build", ReleaseCandidate, ReleasetoProduction promotion steps.

However, when I pull down the template job description, do my replace, and
perform the Create, I'm not getting the Promoted Builds configuration
included in the new job.

I have wrapped all of the Java CLI calls in Powershell, I'd be happy to
send out the script if someone would like to look at it.

Otherwise, any ideas how I can get a New Job created and include the
Promoted Builds configuration?

Note: To fix this I have manually copied the following folders from the
template job to my new job:
promotions\CI-Complete
promotions\DirectedBuild
promotions\QA-Ready
promotions\Release
promotions\ReleaseCandidate
promotions\ReleaseToProduction
promotions\CI-Complete\config.xml
promotions\CI-Complete\nextBuildNumber
promotions\DirectedBuild\config.xml
promotions\DirectedBuild\nextBuildNumber
promotions\QA-Ready\config.xml
promotions\QA-Ready\nextBuildNumber
promotions\Release\config.xml
promotions\Release\nextBuildNumber
promotions\ReleaseCandidate\config.xml
promotions\ReleaseCandidate\nextBuildNumber
promotions\ReleaseToProduction\config.xml
promotions\ReleaseToProduction\nextBuildNumber

I would think the CLI Create command would do all of this.

Thank you.

Mike

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins Plugin for Web.Config Replacement

2014-04-10 Thread Mike Craig
I use a batch process using this project:
https://configgen.codeplex.com/



On Tuesday, April 8, 2014 10:40:09 AM UTC-7, award wrote:
>
> I apologize if this has already been discussed or resolved in advance; 
> however, I can't seem to find the answer i'm looking for.  Maybe I'm not 
> asking it correctly.  Any who... 
>
> We are using Jenkins to poll subversion, build projects, and run unit 
> tests. 
> This is working great!  Now we want to add a step of complexity.  We want 
> to 
> replace values in the Web.Config and App.Config files at different stages. 
> Here is the most basic example: 
>
> In the Web.Config and App.Configs, there will be certain values which we 
> will indicate as replaceable tokens.  These replaceable tokens should be 
> replaced by Jenkins when running a Unit Test.  For example, in my 
> Web.Config 
> file, when the project is built, I will have the following: 
>
>  
>
> Then, when Jenkins goes to run a unit test, I want a plugin which will go 
> through and replace the specified tokens to real values. Is there an 
> existing plugin to do this?  Would a plugin which simply replaces the 
> Web.Config file be of better use? 
>
>
>
> -- 
> View this message in context: 
> http://jenkins-ci.361315.n4.nabble.com/Jenkins-Plugin-for-Web-Config-Replacement-tp4697910.html
>  
> Sent from the Jenkins users mailing list archive at Nabble.com. 
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Perforce-Plugin: How to use variables in the client/view spec?

2014-04-10 Thread Mike Craig
Hello,

I'm trying to make the Perforce Plugin's view spec more dynamic by 
including an Environment variable in the spec, but it doesn't' seem to work 
the way I would expect.

Our specs usually include the Release name:

//base/products/branch/v1.Main/... //VMWIN2K801/products/branch/v1.Main/...

What I would like to do is use the Jenkins job name, or other variable, as 
such:

//sait/VCI/products/branch/%JOB_NAME%/... 
//VMWIN2K801/VCI/products/branch/%JOB_NAME%/...

Is this supported? Or am I doing it wrong?

Thanks,

Mike

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.