Re: BUG with libraryResource : No such library resource null could be found.

2020-12-17 Thread Stuart Rowe
Any chance this is being called from a @NonCPS method? I've seen similar 
behaviour in that case.
On Monday, 14 December 2020 at 14:37:55 UTC-8 yannick...@gmail.com wrote:

> Hi,
>
> In a shared library, in a groovy script in /vars, the following code is 
> working perfectly:
>
> String call(String stageName) {
>   String cowMsg = libraryResource 'cow.txt'
>   if (cowMsg != null) {
> def vars = [:]
> vars['MESSAGE'] = "BEGIN STAGE: ${stageName}"
> def engine = new StreamingTemplateEngine()
> def asciiArtMsg = engine.createTemplate(cowMsg).make(vars).toString()
> echo "${asciiArtMsg}"
> } else {
> echo "I never see that because cowMsg is not null..."
> }
>
> This prints my file cow.txt as expected, because cowMsg is NOT null.
>
> BUT : if I remove the "if", I have this error :
>   No such library resource null could be found.
>
> It is like my resource suddenly became null !
>
> I load some other files without the need of this mysterious "if".
>
> Is that a Groovy bug ?
>
>
>
>

-- 
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/3d05598e-01d9-4a86-9b1d-bc798546b94cn%40googlegroups.com.


Re: How to get command versions supported by Pipeline

2020-10-26 Thread Stuart Rowe
The folder containing the "dotnet" executable/script needs to be added to 
your PATH environment variable. It's likely that the machine where this 
command works already has the "dotnet" folder included in the PATH 
environment variable.

On Tuesday, 13 October 2020 at 07:49:25 UTC-7 venh...@gmail.com wrote:

> Thank you for the response. However, the bat step runs fine in one machine 
> and not the other. The only difference is in the version of .Net Core SDK. 
> That's why I am surprised. Is it looking for an exact version of a specific 
> command? Please let me know.
>
> bat "dotnet restore"
>
> Regards,
> Venkatesh
>
>
> On Tue, Oct 13, 2020 at 7:48 PM Slide  wrote:
>
>> There is no direct support in Jenkins for the dotnet command, if you are 
>> using the bat step, then it should function just like if you ran the 
>> command in cmd.exe as the user that your Jenkins agent is running as. 
>>
>> On Tue, Oct 13, 2020, 07:10 Ven H  wrote:
>>
>>> Thanks a lot for your response. However, I have another slave where it 
>>> works just fine without path. So, I am trying to understand which version 
>>> it supports. Also, I don't want to hardcode the path in the Jenkinsfile. 
>>> Please help.
>>>
>>> Regards,
>>> Venkatesh
>>>
>>>
>>> On Tue, Oct 13, 2020 at 7:14 PM Eric Pyle  wrote:
>>>
 This message is telling you that your "bat" step does not know where to 
 find the "dotnet" command. If you give the full path it should succeed.

 On 10/13/2020 9:33 AM, Ven H wrote:

 In my Jenkinsfile, I am using the following command 

 bat "dotnet restore"

 I have .NET Core SDK installed in the Jenkins Slave, but still the job 
 throws an error saying "'dotnet' is not recognized as an internal or 
 external command,
 operable program or batch file."

 So, how to know which version of .NET Core SDK or for that matter any 
 command (say MSBuild) is supported by the "bat" step of Jenkinsfile.

 Please help.

 Regards,
 Venkatesh
 -- 
 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/CAPp28eqvJyaz_C2G%2Bs2v1V7txGb_tAJoprA6qmUAMRh4Vf%3DQsA%40mail.gmail.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-use...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/jenkinsci-users/a4c84b6c-57fb-0547-d30d-12c6246c5242%40cd-adapco.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-use...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/CAPp28erb5GMhpGyZ%3DKPyw%2BCQRPgqy7a%3DK0L900J5PJAwZtqqkA%40mail.gmail.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-use...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVdxXeFRmnS8ypdp4spPE%3DOkk_8LijVNXnY9rbKnLQ9Pyg%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0a8b93aa-35cd-4a18-969a-1f4cee8c4e3dn%40googlegroups.com.


Re: Get result of build step

2020-09-14 Thread Stuart Rowe
The triggerRemoteJob pipeline step returns a Handle 
,
 
while the build pipeline step returns a RunWrapper 

 when 
wait is enabled (default behavior).

On Monday, 14 September 2020 09:50:33 UTC-7, Marat Gareev wrote:
>
> Hello,
>
> I'm trying to use enum for processing the result of the *build* step.
>
> Working example of using *triggerRemoteJob*:
>
>> def jobBuild = triggerRemoteJob remoteJenkinsName: remoteJenkins, job: 
>> jobName,
>> shouldNotFailBuild: true
>> if (jobBuild.getBuildResult() != Result.SUCCESS) {
>> currentBuild.result = Result.UNSTABLE.toString()
>> }
>
>
> But the same solution for *build* doesn't work (always falls to if 
> statement)
>
>> import hudson.model.Result
>
> ...  
>
> Map job = [:]
>> String jobName = "My-Local-Job"
>> job["job"] = jobName
>> job["parameters"] = [
>> [$class: 'StringParameterValue', name: 'GIT_BRANCH', value: BRANCH]]
>> job["wait"] = true
>> def jobBuild = build job
>>
>> if (jobBuild.getResult() != Result.SUCCESS) {
>> currentBuild.result = Result.FAILURE.toString()
>> error "Build was failed"
>> }
>
>
>  So, I have to work with strings
>
>> String jobResult = jobBuild.getResult()
>> if (jobResult != "SUCCESS") {
>> currentBuild.result = 'FAILURE'
>> error "Build was failed"
>> }
>
>
> How can I use enum with the *build* step? 
>

-- 
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/fc8ecbc7-e06d-4255-9a31-7aa3923da59co%40googlegroups.com.


Re: How to add parameters to existing parameters list?

2020-08-04 Thread Stuart Rowe
You can configure the parameters for the current job (in a Scripted 
Pipeline) with:

def parameterList = [stringParam(name: 'Test', value: 'TestValue')]
properties(parameters(parameterList)

This will replace all parameters of your job with the contents of 
parameterList.


On Monday, 3 August 2020 23:03:39 UTC-7, Gajanan Mahajan wrote:
>
> I get all parameters of a build using -
>
> def myparams = 
> currentBuild.rawBuild.getAction(ParametersAction).getParameters()
>
> `myparams` is object of 
> `java.util.Collections$UnmodifiableRandomAccessList` hence if try  to add 
> another parameter to it like  -
>
> myparams.add([$class: 'StringParameterValue', name: 'Test', value: 
> "TestValue"])
>
> then it fails with error - 
>
> java.lang.UnsupportedOperationException
>
> Please guide how to add parameter to existing parameters.
>

-- 
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/723fed16-1561-4e23-b925-f3e01778f8bdo%40googlegroups.com.


Re: Hi friend i have 2 lockable resource while executing same job 2 times i want 2nd job will move 2nd lcokable resource how can i do it

2020-05-03 Thread Stuart Rowe
That's disappointing. Perhaps you can report this issue to the plugin 
maintainers? That is the use case for the skipIfLocked feature.

-- 
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/8bb65716-9858-4eec-923e-941e45c4927f%40googlegroups.com.


Re: Hi friend i have 2 lockable resource while executing same job 2 times i want 2nd job will move 2nd lcokable resource how can i do it

2020-05-01 Thread Stuart Rowe
Do you have release 2.8 installed? 
https://github.com/jenkinsci/lockable-resources-plugin/releases/tag/lockable-resources-2.8

-- 
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/d68ec931-1d2a-4d17-8cc9-e4bb39b40195%40googlegroups.com.


Re: Hi friend i have 2 lockable resource while executing same job 2 times i want 2nd job will move 2nd lcokable resource how can i do it

2020-05-01 Thread Stuart Rowe
I agree with Christoph that there are better approaches. However, if you 
really want to do this you can use the new skipIfLocked feature added in 
lockable-resource 
2.8 

:
pipeline {
   agent any
   stages {
   stage('sample_1') {
   steps { 
script {
   def lockedResource1 = false
   lock(label: 'Resource1', skipIfLocked: true) {
   lockedResource1  = true
sh label: '', script: 'echo $JAVA_HOME'
   sleep time: 1, unit: 'MINUTES'
   } 
if (!lockedResource1)
   lock(label: 'Resource2') { 
sh label: '', script: 'echo $JAVA_HOME'
   sleep time: 1, unit: 'MINUTES'
   }
   }
   }
   }
   }
   }
}




On Thursday, 30 April 2020 07:27:52 UTC-7, Christoph Fetzer wrote:
>
> Don't you actually want to use a ressource pool with two locks which use 
> the same label?
>
> Am Donnerstag, 30. April 2020 15:46:28 UTC+2 schrieb Satya Muralidhar 
> Peddireddi:
>>
>> It's my test case I want run same job parallely in different locks.if one 
>> lock is busy go to another lock
>>
>> On Thu, Apr 30, 2020, 14:24 Gianluca  wrote:
>>
>>>
>>> It's not really clear what you want ... but nevertheless I think you 
>>> have got the solution.
>>> You have an "if" ... you just need to figure it out what is the 
>>> condition that makes you go to the else branch.
>>>
>>> So, why one job should lock "Resource 1" and another should "Resource 2"?
>>>
>>>
>>> On Thursday, 30 April 2020 09:37:41 UTC+1, Satya Muralidhar Peddireddi 
>>> wrote:

 pipeline {
 agent any
 stages {
 stage('sample_1') {
 steps { 
 script {
 if(true) {
 lock(label: 'Resource1') {
 sh label: '', script: 'echo $JAVA_HOME'
 sleep time: 1, unit: 'MINUTES'
 }   
 } 
 else{
 lock(label: 'Resource2') { 
 sh label: '', script: 'echo $JAVA_HOME'
 sleep time: 1, unit: 'MINUTES'
 }
 }
 }
 }
 }
 }
 }


 -- 
>>> 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 jenkins...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/56d4aaa9-5435-4a18-ac5a-a4659222538e%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/2129e9ad-9629-41e3-9c92-525705b71295%40googlegroups.com.


Re: Parallel pipeline and Stage View

2020-02-23 Thread Stuart Rowe
If the subversion plugin produces a changeset for a run, then blueocean should 
be able to display that. Subversion wouldn't be supported when using blueocean 
to author pipelines though.

-- 
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/135c8f06-7748-499a-b9b0-603549828d01%40googlegroups.com.


Re: Return value of build Pipeline step - What is it?

2019-07-11 Thread Stuart Rowe
The return value is a RunWrapper 

 as 
long as wait is set to true.

On Thursday, 11 July 2019 06:58:13 UTC-7, George Sexton wrote:
>
> Can anyone help me understand what if any the return value is for the 
> build pipeline step? I've read the docs here:
>
>
> https://jenkins.io/doc/pipeline/steps/pipeline-build-step/#-build-%20build%20a%20job
>
> There's a vague reference here:
>
> propagate (optional)
>
> If set, then if the downstream build is anything but successful (blue 
> ball), this step fails. If disabled, then this step succeeds even if the 
> downstream build is unstable, failed, etc.; use the result property of 
> the return value as needed.
>
>
>
>

-- 
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/f62cfa21-6bee-47fe-af42-31fe557e048c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unable to open a JIRA issue

2019-04-16 Thread Stuart Rowe
I'm having the same issue. Perhaps this should be cross posted to the Jenkins 
Developers group as well?

-- 
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/8c8c5542-b6ff-4406-ace3-4151de3dd13a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins Performance loading slow

2019-03-19 Thread Stuart Rowe
Since you have the Active Directory plugin installed, can you confirm that 
you have caching enabled? We were bit by this when upgrading a test 
instance to LTS 2.150.2.
See: https://issues.jenkins-ci.org/browse/JENKINS-56243

-- 
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/86e78949-8421-4ba0-93a8-630bcda36495%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Security - Pipeline parameterized credentials can be reused by other users

2019-03-15 Thread Stuart Rowe
I can't provide you with a step by step solution as it depends on how 
security and authorization is configured on your Jenkins instance. You 
should be able to find a lot of information on controlling Jenkins 
job/build permissions with a quick internet search.

On Thursday, 14 March 2019 22:55:46 UTC-7, Sarfroz Basha wrote:
>
>
>
> On Thursday, March 14, 2019 at 10:10:50 PM UTC+5:30, Stuart Rowe wrote:
>>
>> Could you remove build permissions on that job for the users that don't 
>> know the credentials? They wouldn't be able to run the job anyways. That 
>> should also remove their ability to replay the job as far as I understand.
>
>
>
> Hi,
>
>
>  
>
>> Thanks for your reply.
>
>  
>
>> Can you elaborate clearly by steps.
>
>  
>

-- 
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/6815b1de-5ee2-4f61-bcaa-f81bb65bd09e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from Jenkins LTS 2.150.1 to 2.150.2 - Slowness and Workaround

2019-03-15 Thread Stuart Rowe
This has been reported 
in https://issues.jenkins-ci.org/browse/JENKINS-56243. Unfortunately the 
workaround is only temporary.

On Friday, 8 February 2019 00:57:53 UTC-8, Kurt Routley, MSc wrote:
>
> Hello,
>
>
> After upgrading from Jenkins LTS 2.150.1 to 2.150.2, we observed 
> significant slowdown when loading any page on Jenkins. Load times were 
> previously sub-second, and were now taking 4 seconds or longer after the 
> upgrade.
>
>  
>
> Workaround for this was to clear cookies from the local browser for the 
> Jenkins instance. After re-login to Jenkins, load times were back to normal 
> for the user.
>
>  
>
> Since the security advisory for 
> https://jenkins.io/security/advisory/2019-01-16/ was the main motivation 
> for the upgrade, you may want to mention in the security advisory about the 
> additional step for users to clear their cookies for the Jenkins instance, 
> as the pre-existing cookies appear to be incompatible.
>
>  
>
> Thanks,
>
> - Kurt Routley, MSc 
>

-- 
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/d977897d-14f5-47d8-94ab-949f07fa2d06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Security - Pipeline parameterized credentials can be reused by other users

2019-03-14 Thread Stuart Rowe
Could you remove build permissions on that job for the users that don't know 
the credentials? They wouldn't be able to run the job anyways. That should also 
remove their ability to replay the job as far as I understand.

-- 
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/3a0f150e-9db6-45a0-ac39-85e0c423369b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to enable logging per file/package

2019-01-25 Thread Stuart Rowe
Hi Gerry,

Create a new named Log Recorder and then configure it following the 
instructions. Within the configuration page, add a new a Logger for 
hudson.model.Queue.

You can see where the logger is initialized here: Queue.java#L2792 
.
 
The loggers are typically identified by class name. 

Hope that helps.

Stuart


On Friday, 25 January 2019 12:24:18 UTC-8, Gerry Storm wrote:
>
> I built Jenkins from the source and want to enable logging available in 
> some Jenkins source files.
>
> How do I do this?
>
> I tried to follow the instructions in 
> https://wiki.jenkins.io/display/JENKINS/Logging but did not get much 
> mileage.
> The page says "Tell us the symptom of your problem in the users list and 
> we should be able to tell you where you need to look at"
>
> How do I enable logging in say core/src/main/java/hudson/model/Queue.java?
>

-- 
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/adf365e7-fc1e-457e-ae3a-67263132f140%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding files before zipping (pipeline utility plugin Jenkins)

2018-11-15 Thread Stuart Rowe
Have you tried copying the *README.md* into *directory/to/my/folder* before 
calling *zip*?

On Thursday, 15 November 2018 09:38:27 UTC-8, Faad Sayaou wrote:
>
> Hello,
> I currently have a pipeline which zips results of a build stage. I have a 
> README.md file which i will like to add in my zip file when uploading to 
> nexus. The file is included during checkout. how do I add this during the 
> zip stage? I tried the approach below but it doesn't add the readme file in 
> my final output folder
>
> *zip dir: 'directroy/to/my/folder', glob:'', zipFile: 'folder.zip'  + 
> 'path/to/my/readmeFile/README.md'*
>
>
> Can someone tell me the correct way of doing this?
> Thanks
>
>
>

-- 
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/bb0ab981-f85b-4ad9-a6ab-f6693f8e1475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installing Artifactory and Blue Ocean plugins offline

2018-10-10 Thread Stuart Rowe
Does anyone know if juseppe works with an existing artifactory instance?

-- 
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/896a5023-c076-4130-94a1-0da96f5debd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Scripted pipeline: Is a job triggered by pipelineTrigger?

2018-08-14 Thread Stuart Rowe
You can check the Run instance for a TimerTriggerCause. See: 
https://javadoc.jenkins-ci.org/hudson/model/Run.html#getCause-java.lang.Class-

Since this is in pipeline, you would need to access the Run within a 
@NonCPS method. Also, you would need to whitelist the RunWrapper#getRawBuild 

 method.

import hudson.triggers.TimerTrigger.TimerTriggerCause
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper

@NonCPS
boolean wasTriggeredByTimer(RunWrapper runWrapper) {
  return null != runWrapper.getRawBuild().getCause(TimerTriggerCause.class)
}

// used within a pipeline script
if (wasTriggeredByTimer(currentBuild)) {
echo("This build was triggered by a timer.")
}


Hope that helps!


On Tuesday, 14 August 2018 02:07:43 UTC-7, Markus "Shorty" Uckelmann wrote:
>
> Hi all, 
>
> I use the following code to trigger a job on a daily basis: 
>
> properties([[$class: 'BuildDiscarderProperty', 
>  strategy: [$class: 'LogRotator', numToKeepStr: '10']], 
>  pipelineTriggers([cron( env.BRANCH_NAME == 'master' ? 
> '@hourly' : '' )]), 
>  ]) 
>
> Now I'd like to know, if the job was triggered by the cron trigger. Does 
> anybody know how this can be done? 
>
> I already tried this peace: 
>
> if (manager.logContains("Started by timer")){ 
>echo "This build was triggered by a timer." 
> } 
>
> But it gave me the error: groovy.lang.MissingPropertyException: No such 
> property: manager for class: groovy.lang.Binding 
>
>
> Cheers, Shorty 
>
>

-- 
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/70a6f039-b21b-4d5f-a6b9-6b67fca05ea0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Email-ext] Resolving email address from Cause.UserIdCause

2014-11-03 Thread Stuart Rowe
BTW, it looks like this PR: 
https://github.com/jenkinsci/build-flow-plugin/pull/53 will fix this 
properly so no more hacky scripts will be needed

On Saturday, 1 November 2014 00:21:02 UTC-7, Nick Dierauf wrote:
>
> Thanks Stuart!
> Nick.
>
> On Wednesday, October 29, 2014 12:43:56 PM UTC-7, Stuart Rowe wrote:
>>
>> Here you go :)
>>
>>
>> import javax.mail.Message
>> import hudson.model.*
>> import com.cloudbees.plugins.flow.*
>> import hudson.tasks.MailAddressResolver
>>
>> def getUpstreamBuild(AbstractBuild curBuild)
>> {
>> upStreamBuild = null
>> if(curBuild != null)
>> {
>> // find a cause that will lead to an upstream build
>> for( cause in curBuild.causes )
>> {
>> if(cause instanceof Cause.UpstreamCause)
>> {
>> upStreamBuild = 
>> Hudson.instance.getItem(cause.upstreamProject).getBuildByNumber(cause.upstreamBuild)
>> break
>> }
>> else if(cause instanceof FlowCause)
>> {
>> upStreamBuild = cause.getFlowRun()
>> break
>> }
>> }
>> }
>> return upStreamBuild
>> }
>>
>> def getUserIdCause(AbstractBuild curBuild)
>> {
>> def userIdCause = null
>> if (curBuild != null)
>> {
>> for( cause in curBuild.causes )
>> {
>> if(cause instanceof Cause.UserIdCause)
>> {
>> userIdCause = cause
>> break
>> }
>> }
>> }
>>
>> return userIdCause
>> }
>>
>> def getEmailFromUserId(userId)
>> {
>> email = null
>> user = User.get(userId, false, [:])
>> if(user)
>> {
>> email = MailAddressResolver.resolve(user)
>> }
>> return email
>> }
>>
>> def getRootRequesterUserEmail()
>> {
>> try
>> {
>> // try to find a user ID cause for the current build
>> def userIdCause = getUserIdCause(build)
>> if(userIdCause != null)
>> {
>> return getEmailFromUserId(userIdCause.getUserId())
>> }
>>
>> def rootBuild = null
>> def curUpstreamBuild = getUpstreamBuild(build)
>>
>> // find the top level build
>> while(curUpstreamBuild)
>> {
>> rootBuild = curUpstreamBuild
>> curUpstreamBuild = getUpstreamBuild(curUpstreamBuild)
>> }
>>
>> // try to find a user ID cause from the top level build
>> userIdCause = getUserIdCause(rootBuild)
>> if(userIdCause != null)
>> {
>> return getEmailFromUserId(userIdCause.getUserId())
>> }
>> }
>> catch (e)
>> {
>> println e
>> }
>> return  null
>> }
>>
>> // update the recipients with the requester from the top level build
>> def userEmail = getRootRequesterUserEmail()
>> return userEmail
>>
>>
>> On Tue, Oct 28, 2014 at 6:17 PM, Nick Dierauf  wrote:
>>
>>> Stuart, can you post the groovy script that you use to determine the 
>>> email address (ie, "myscript.groovy")?
>>> Thanks!
>>> Nick.
>>>
>>>
>>> On Tuesday, March 11, 2014 11:24:37 AM UTC-7, Stuart Rowe wrote:
>>>>
>>>> Hi, does anyone know of a way to look up a user's email address from 
>>>> their user ID? I can't make the assumption that the email is "
>>>> use...@company.com" because I know this isn't always the case.
>>>>
>>>> We're using the Active Directory plugin for security which is where the 
>>>> email addresses for users are coming from. I need to manually add the 
>>>> requester to the recipient list because this doesn't seem to be propagated 
>>>> by BuildFlow FlowCauses. The relevant parts of build pipeline in this case 
>>>> is:
>>>>
>>>> BuildFlow project A (scheduled by the logged in user) --> Build Flow 
>>>> project B --> Free Style Project with an Editable Email Notification post 
>>>> build step.
>>>>
>>>> Thanks in advance, 
>>>>
>>>> Stuart
>>>>
>>>  -- 
>>> 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/nQtro7RisO4/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to 
>>> jenkinsci-use...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


Re: [Email-ext] Resolving email address from Cause.UserIdCause

2014-10-29 Thread Stuart Rowe
Here you go :)


import javax.mail.Message
import hudson.model.*
import com.cloudbees.plugins.flow.*
import hudson.tasks.MailAddressResolver

def getUpstreamBuild(AbstractBuild curBuild)
{
upStreamBuild = null
if(curBuild != null)
{
// find a cause that will lead to an upstream build
for( cause in curBuild.causes )
{
if(cause instanceof Cause.UpstreamCause)
{
upStreamBuild =
Hudson.instance.getItem(cause.upstreamProject).getBuildByNumber(cause.upstreamBuild)
break
}
else if(cause instanceof FlowCause)
{
upStreamBuild = cause.getFlowRun()
break
}
}
}
return upStreamBuild
}

def getUserIdCause(AbstractBuild curBuild)
{
def userIdCause = null
if (curBuild != null)
{
for( cause in curBuild.causes )
{
if(cause instanceof Cause.UserIdCause)
{
userIdCause = cause
break
}
}
}

return userIdCause
}

def getEmailFromUserId(userId)
{
email = null
user = User.get(userId, false, [:])
if(user)
{
email = MailAddressResolver.resolve(user)
}
return email
}

def getRootRequesterUserEmail()
{
try
{
// try to find a user ID cause for the current build
def userIdCause = getUserIdCause(build)
if(userIdCause != null)
{
return getEmailFromUserId(userIdCause.getUserId())
}

def rootBuild = null
def curUpstreamBuild = getUpstreamBuild(build)

// find the top level build
while(curUpstreamBuild)
{
rootBuild = curUpstreamBuild
curUpstreamBuild = getUpstreamBuild(curUpstreamBuild)
}

// try to find a user ID cause from the top level build
userIdCause = getUserIdCause(rootBuild)
if(userIdCause != null)
{
return getEmailFromUserId(userIdCause.getUserId())
}
}
catch (e)
{
println e
}
return  null
}

// update the recipients with the requester from the top level build
def userEmail = getRootRequesterUserEmail()
return userEmail


On Tue, Oct 28, 2014 at 6:17 PM, Nick Dierauf  wrote:

> Stuart, can you post the groovy script that you use to determine the email
> address (ie, "myscript.groovy")?
> Thanks!
> Nick.
>
>
> On Tuesday, March 11, 2014 11:24:37 AM UTC-7, Stuart Rowe wrote:
>>
>> Hi, does anyone know of a way to look up a user's email address from
>> their user ID? I can't make the assumption that the email is "
>> use...@company.com" because I know this isn't always the case.
>>
>> We're using the Active Directory plugin for security which is where the
>> email addresses for users are coming from. I need to manually add the
>> requester to the recipient list because this doesn't seem to be propagated
>> by BuildFlow FlowCauses. The relevant parts of build pipeline in this case
>> is:
>>
>> BuildFlow project A (scheduled by the logged in user) --> Build Flow
>> project B --> Free Style Project with an Editable Email Notification post
>> build step.
>>
>> Thanks in advance,
>>
>> Stuart
>>
>  --
> 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/nQtro7RisO4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-users+unsubscr...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


Re: LDAP configuration in jenkins

2014-07-29 Thread Stuart Rowe
Using the AD plugin you can list multiple domain controllers in the 
advanced configuration section. 

On Tuesday, 29 July 2014 09:59:58 UTC-7, alok kumar wrote:
>
> Hi All,
> We have a requirement where in we would like to configure Jenkins users to 
> be authenticated by seeing up LDAP.
>
> The problem here is we have these users working in different domains. So, 
> how can I setup LDAP for users present in different domains as I see only 
> one set of configuration that can be set in Jenkins.
>
> Also does Jenkins support configuring users from an AD forest.
>
> Any help would be greatly appreciated.
>
> Thanks,
> Alok
>

-- 
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: Perforce: merge files from a continuous directory to an integration directory...

2014-05-09 Thread Stuart Rowe
Yes, the p4 commands can just be in a windows batch command build step. I'm
not sure how you're building / testing though.

Keep in mind that the p4 commands I suggested will open files for integrate
in the default changelist.
On May 9, 2014 10:21 AM, "Mark Wilhelm" 
wrote:

> Thanks, I'll give it a go.  For #4, are you putting these into a "Execute
> Windows batch command" build step"?
>
> On Wednesday, May 7, 2014 2:18:57 PM UTC-5, Stuart Rowe wrote:
>>
>> Try this approach (there may be typos / gotchas - it's completely
>> untested)
>>
>> 1) Enable Perforce SCM on your integration project in Jenkins
>> - set up the client spec 'myclientspec' to use the mapping:
>>//project/dev/... //myclientspec/dev/...
>>//project/int/... //myclientspec/int/...
>>
>> 2)  Enable 'Use View Mask', but just for polling (I haven't tried this
>> feature yet so I'm just guessing it will work for you)
>>  - set the view mask to be //project/dev/...
>>
>> 3) Under Build Triggers, check Poll SCM
>> - any submitted changes under the //project/int/... branch should now
>> trigger your integration project in Jenkins
>> - since we're NOT using the view mask for syncing, both branches will
>> be synced to head when the build starts (this is good for continuous
>> integration)
>> - perforce plugin stores the changelist it sync'd to in the
>> environment variable 'P4_CHANGELIST' (this is the latest changelist in the
>> Dev branch that triggered the build!)
>>
>> 4) Now we want to integrate from the Dev banch to the integration branch:
>>
>>p4 integrate -d -i -t //project/dev/...@%P4_CHANGELIST%
>> //project/int/...
>>p4 resolve -a
>>
>>// test the build
>>
>>   p4 submit -f revertunchanged -d "Integration Build"
>>
>> On Wednesday, 7 May 2014 11:09:17 UTC-7, Mark Wilhelm wrote:
>>>
>>> ok, some more "work"...
>>>
>>> I put these commands in the "EWbc" window and it works:
>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx change -o
>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx integrate -d -i -t
>>> //Project/dev... //Workspace/Project/int...
>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx resolve -a
>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx submit -f
>>> revertunchanged -d "Integration Build"
>>>
>>> BUT, if I run it again, it fails:
>>> "No files to submit from the default changelist.
>>>
>>> D:\workspaces>exit 1"
>>>
>>> While this makes sense, is there: 1) a way to suppress the submit from
>>> returning a non-zero (i.e. an error) or 2) A better way altogether?
>>>
>>>
>>> Thanks...
>>>
>>> On Wednesday, May 7, 2014 9:01:04 AM UTC-5, Mark Wilhelm wrote:
>>>>
>>>> Just a basic setup:
>>>> depot/project/dev/src
>>>> depot/project/int/src
>>>>
>>>> I have a continuous build running on the "dev" structure every few
>>>> minutes. I have a nightly build that runs on the "int" structure. When you
>>>> ask "why don't you want to merge?", are you asking from a manual
>>>> perspective?
>>>>
>>>> I would like my "dev" build to run. When the "int" build runs, I would
>>>> like it to check if there were any changes on the "dev" branch/directory
>>>> and move them over. Then build what's there.
>>>>
>>>> I have used some of the commands in a "Execute Windows batch command"
>>>> build step, but thought that the "Source Code Management" plugin would be
>>>> where I would want to do that.
>>>>
>>>> In the window I used the following commands:
>>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx change -o
>>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx integrate -i -d -t
>>>> //project/dev... //JenkinsJob/workspace/int...
>>>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx submit -f
>>>> revertunchanged -d "Integration Build"
>>>>
>>>> On the integrate I get: - all revision(s) already integrated.
>>>> On the integrate I get: No files to submit from the default changelist.
>>>> and the &quo

Re: Perforce: merge files from a continuous directory to an integration directory...

2014-05-07 Thread Stuart Rowe
Try this approach (there may be typos / gotchas - it's completely untested)

1) Enable Perforce SCM on your integration project in Jenkins
- set up the client spec 'myclientspec' to use the mapping:
   //project/dev/... //myclientspec/dev/...
   //project/int/... //myclientspec/int/...

2)  Enable 'Use View Mask', but just for polling (I haven't tried this 
feature yet so I'm just guessing it will work for you)
 - set the view mask to be //project/dev/...

3) Under Build Triggers, check Poll SCM
- any submitted changes under the //project/int/... branch should now 
trigger your integration project in Jenkins
- since we're NOT using the view mask for syncing, both branches will 
be synced to head when the build starts (this is good for continuous 
integration)
- perforce plugin stores the changelist it sync'd to in the environment 
variable 'P4_CHANGELIST' (this is the latest changelist in the Dev branch 
that triggered the build!)

4) Now we want to integrate from the Dev banch to the integration branch:

   p4 integrate -d -i -t //project/dev/...@%P4_CHANGELIST% //project/int/...
   p4 resolve -a 

   // test the build

  p4 submit -f revertunchanged -d "Integration Build" 

On Wednesday, 7 May 2014 11:09:17 UTC-7, Mark Wilhelm wrote:
>
> ok, some more "work"...
>
> I put these commands in the "EWbc" window and it works:
> "C:\Program Files\Perforce\"p4 -u build-user -P xxx change -o
> "C:\Program Files\Perforce\"p4 -u build-user -P xxx integrate -d -i -t 
> //Project/dev... //Workspace/Project/int...
> "C:\Program Files\Perforce\"p4 -u build-user -P xxx resolve -a
> "C:\Program Files\Perforce\"p4 -u build-user -P xxx submit -f 
> revertunchanged -d "Integration Build" 
>
> BUT, if I run it again, it fails:
> "No files to submit from the default changelist.
>
> D:\workspaces>exit 1"
>
> While this makes sense, is there: 1) a way to suppress the submit from 
> returning a non-zero (i.e. an error) or 2) A better way altogether?
>
>
> Thanks...
>
> On Wednesday, May 7, 2014 9:01:04 AM UTC-5, Mark Wilhelm wrote:
>>
>> Just a basic setup:
>> depot/project/dev/src
>> depot/project/int/src
>>
>> I have a continuous build running on the "dev" structure every few 
>> minutes. I have a nightly build that runs on the "int" structure. When you 
>> ask "why don't you want to merge?", are you asking from a manual 
>> perspective? 
>>
>> I would like my "dev" build to run. When the "int" build runs, I would 
>> like it to check if there were any changes on the "dev" branch/directory 
>> and move them over. Then build what's there.
>>
>> I have used some of the commands in a "Execute Windows batch command" 
>> build step, but thought that the "Source Code Management" plugin would be 
>> where I would want to do that.
>>
>> In the window I used the following commands:
>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx change -o
>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx integrate -i -d -t 
>> //project/dev... //JenkinsJob/workspace/int...
>> "C:\Program Files\Perforce\"p4 -u build-user -P xxx submit -f 
>> revertunchanged -d "Integration Build"
>>
>> On the integrate I get: - all revision(s) already integrated.
>> On the integrate I get: No files to submit from the default changelist.
>> and the "Execute Windows batch command" fails the build "Build step 
>> 'Execute Windows batch command' marked build as failure. Even though there 
>> was a change list listed by Jenkins.
>>
>> I'm all for changing my direction if there is a more standard/better way 
>> of implementing this.
>>
>> Thoughts?
>>
>>
>>
>> On Wednesday, May 7, 2014 2:58:51 AM UTC-5, Stuart Rowe wrote:
>>>
>>> Can you describe your branch structure a little more?
>>>
>>> How are your integration builds triggered? If you're trying to move 
>>> changes from your development branch to another branch why don't you want 
>>> to merge? 
>>>
>>> Conceptually I would approach this as:
>>>
>>> 1)  start an integration of your Dev branch up to some changelist to the 
>>> target branch
>>>
>>> (look up "p4 integrate")
>>>
>>>
>>> 2) now you have a pending integration changelist with the changes from 
>>> your Dev branch applied to your target branch. (assuming there were no 
>>> conflicts that couldn't be resolved).
>>>
>>> Run whatever builds/tests you have set up to verify the changes
>>>
>>> 3) a) if the builds and tests were successful, submit the changelist
>>>
>>> (look up "p4 submit")
>>>
>>> b) if anything failed, revert the changelist and make the appropriate 
>>> fixes in your Dev branch
>>>
>>>

-- 
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: merge files from a continuous directory to an integration directory...

2014-05-07 Thread Stuart Rowe
Can you describe your branch structure a little more?

How are your integration builds triggered? If you're trying to move changes 
from your development branch to another branch why don't you want to merge? 

Conceptually I would approach this as:

1)  start an integration of your Dev branch up to some changelist to the target 
branch

(look up "p4 integrate")


2) now you have a pending integration changelist with the changes from your Dev 
branch applied to your target branch. (assuming there were no conflicts that 
couldn't be resolved).

Run whatever builds/tests you have set up to verify the changes

3) a) if the builds and tests were successful, submit the changelist

(look up "p4 submit")

b) if anything failed, revert the changelist and make the appropriate fixes in 
your Dev branch

-- 
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: BUILD FLOW parallel closure simple example

2014-05-01 Thread Stuart Rowe
t;http://localhost:8082/job/TestParameterized/>*d*
>
>  ... truncated for brevity
>
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
>
> *... (truncated for brevity)*
>
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Schedule job TestParameterized 
> <http://localhost:8082/job/TestParameterized/>
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> Build TestParameterized #6 
> <http://localhost:8082/job/TestParameterized/6/> started
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
>
> *... (truncated for brevity)*
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> TestParameterized #6 <http://localhost:8082/job/TestParameterized/6/> 
> completed
> Build TestParameterized #7 
> <http://localhost:8082/job/TestParameterized/7/> started
> Build TestParameterized #7 
> <http://localhost:8082/job/TestParameterized/7/> started
>
> *... (truncated for brevity)*
>
> Build TestParameterized #7 
> <http://localhost:8082/job/TestParameterized/7/> started
> Build TestParameterized #7 
> <http://localhost:8082/job/TestParameterized/7/> started
> TestParameterized #7 <http://localhost:8082/job/TestParameterized/7/> 
> completed
>
> *... (truncated for brevity)*
> TestParameterized #7 <http://localhost:8082/job/TestParameterized/7/> 
> completed
> }
> Finished: SUCCESS
>
>
> *TestParameterized *contains two runs 6,7 each containing the following 
> console output:
>
>
> Started by build flow TestJobDSL#114
> Started by build flow TestJobDSL#114
>
> *... (truncated for brevity)*
>
> Started by build flow TestJobDSL#114 Started by build flow TestJobDSL#114
> [EnvInject] - Loading node environment variables. Building remotely on
> Slave1 <http://localhost:8082/computer/Slave1> in workspace
> c:\Slave1RemoteFS\workspace\TestParameterized [TestParameterized] $ cmd /c
> call C:\Users\XX\AppData\Local\Temp\hudson2441697324175984667.bat
> c:\Slave1RemoteFS\workspace\TestParameterized>echo 50 50
> c:\Slave1RemoteFS\workspace\TestParameterized>exit 0 Finished: SUCCESS
>
>
>
> As you can see only the terminal loop value "50" is used.
>
>
> What do you get when you run the examples above?
>
>
> Thanks
>
>
>
> On Mon, Apr 28, 2014 at 12:27 AM, Stuart Rowe wrote:
>
>> As Marc pointed out, the variable "i" isn't private to each closure
>> because it's defined outside of the scope.
>>
>> One solution would be to copy the value of i to a variable defined within
>> the scope of the closure:
>>
>>
>> for (int i=1; i<50; i++) {
>> def curClosure = {
>> def j = i
>> build("TestParameterized", Parameter: j)
>> }
>> buildClosures.add(curClosure)
>> }
>>
>> Because each of your schedule jobs for TestParamaterized had the same 
>>

Re: BUILD FLOW parallel closure simple example

2014-04-28 Thread Stuart Rowe
As Marc pointed out, the variable "i" isn't private to each closure because 
it's defined outside of the scope.

One solution would be to copy the value of i to a variable defined within 
the scope of the closure:


for (int i=1; i<50; i++) {
def curClosure = {
def j = i
build("TestParameterized", Parameter: j)
}
buildClosures.add(curClosure)
}

Because each of your schedule jobs for TestParamaterized had the same 
parameters, the Jenkins scheduler actually merged the tasks to reduce 
redundancies.


On Wednesday, 23 April 2014 13:52:46 UTC-7, pjl8...@gmail.com wrote:
>
> Thanks for the suggestion.. .but same result
>
> On Wednesday, April 23, 2014 11:55:29 AM UTC-7, Marc MacIntyre wrote:
>>
>> I assume that you only end up defining one curClosure variable, since it 
>> never goes out of scope, and subsequent changes to it update the one 
>> version you've added to your buildClosures list.
>>
>> Maybe you want buildClosures.add(curClosure.clone()) 
>>
>

-- 
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: [Email-ext] Resolving email address from Cause.UserIdCause

2014-03-11 Thread Stuart Rowe
Perfect, thanks again.

On Tuesday, 11 March 2014 13:15:42 UTC-7, slide wrote:
>
> You don't need to resolve the addresses yourself if you are using a SCRIPT 
> token, the email-ext plugin will resolve them after it replaces the tokens. 
> Yes, you can have the $DEFAULT_RECIPIENTS and ${SCRIPT...} tokens in the 
> edit box and it will work just fine.
>
>
> On Tue, Mar 11, 2014 at 12:44 PM, Stuart Rowe 
> > wrote:
>
>> I just found the MailAddressResolver class on my own and it's solved the 
>> problem.
>>
>> Currently I'm adding recipients by referencing a groovy script directly 
>> in the project recipients edit box (e.g. ${SCRIPT, 
>> script="myscript.groovy"} ). The script recursively looks up the requesting 
>> userId from the top level build and that is used to get a Jenkins User 
>> which is passed to MailAddressResolver.resolve(). The script returns the 
>> address returned by resolve(). 
>>
>> Is this the best approach? It'd be nice to keep the default recipient and 
>> append the resolved recipient - can I just put $DEFAULT_RECIPIENT,${SCRIPT, 
>> script="myscript.groovy"} in the edit box? 
>>
>> Thanks for your help!
>>
>>
>> On Tuesday, 11 March 2014 12:29:10 UTC-7, slide wrote:
>>
>>> How are you planning, in your groovy script to add the users as 
>>> recipients? Just a curiosity. You could call the MailAddressResolver 
>>> resolve method yourself from the groovy script in each recipient, but you 
>>> may not need to do that depending on how you are adding the recipients.
>>> On Mar 11, 2014 11:56 AM, "Stuart Rowe"  wrote:
>>>
>>>> Sorry for the confusion:
>>>>
>>>> If a user schedules a single project that has an email post build step 
>>>> than the email address is resolved automatically by the Active Directory 
>>>> plugin.
>>>>
>>>> I'm having problems with a more complicated build pipeline where the 
>>>> requesting user isn't propagated to a down stream build that has an email 
>>>> step. I'm attempting to write a groovy script that will set the email 
>>>> recipients to the requester of the top level build. I've managed to look 
>>>> up 
>>>> the user ID from the UserIdCause of the top level build, but I haven't 
>>>> found a way to resolve an email address from that user id.
>>>>
>>>> I hope that's more clear now :).
>>>>
>>>>
>>>> On Tuesday, 11 March 2014 11:33:47 UTC-7, slide wrote:
>>>>>
>>>>> You could use the mailmap-resolver-plugin, but I may be missing 
>>>>> something because there seems to be a discrepancy with what you are 
>>>>> saying. 
>>>>> First you need to look up the user's email address from their user ID, 
>>>>> but 
>>>>> then you say you are getting email addresses from Active Directory? Can 
>>>>> you 
>>>>> clarify.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> slide
>>>>>
>>>>>
>>>>> On Tue, Mar 11, 2014 at 11:24 AM, Stuart Rowe wrote:
>>>>>
>>>>>> Hi, does anyone know of a way to look up a user's email address from 
>>>>>> their user ID? I can't make the assumption that the email is "
>>>>>> use...@company.com" because I know this isn't always the case.
>>>>>>
>>>>>> We're using the Active Directory plugin for security which is where 
>>>>>> the email addresses for users are coming from. I need to manually add 
>>>>>> the 
>>>>>> requester to the recipient list because this doesn't seem to be 
>>>>>> propagated 
>>>>>> by BuildFlow FlowCauses. The relevant parts of build pipeline in this 
>>>>>> case 
>>>>>> is:
>>>>>>
>>>>>> BuildFlow project A (scheduled by the logged in user) --> Build Flow 
>>>>>> project B --> Free Style Project with an Editable Email Notification 
>>>>>> post 
>>>>>> build step.
>>>>>>
>>>>>> Thanks in advance, 
>>>>>>
>>>>>> Stuart
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>

Re: [Email-ext] Resolving email address from Cause.UserIdCause

2014-03-11 Thread Stuart Rowe
I just found the MailAddressResolver class on my own and it's solved the 
problem.

Currently I'm adding recipients by referencing a groovy script directly in 
the project recipients edit box (e.g. ${SCRIPT, script="myscript.groovy"} 
). The script recursively looks up the requesting userId from the top level 
build and that is used to get a Jenkins User which is passed to 
MailAddressResolver.resolve(). The script returns the address returned by 
resolve(). 

Is this the best approach? It'd be nice to keep the default recipient and 
append the resolved recipient - can I just put $DEFAULT_RECIPIENT,${SCRIPT, 
script="myscript.groovy"} in the edit box? 

Thanks for your help!


On Tuesday, 11 March 2014 12:29:10 UTC-7, slide wrote:
>
> How are you planning, in your groovy script to add the users as 
> recipients? Just a curiosity. You could call the MailAddressResolver 
> resolve method yourself from the groovy script in each recipient, but you 
> may not need to do that depending on how you are adding the recipients.
> On Mar 11, 2014 11:56 AM, "Stuart Rowe" > 
> wrote:
>
>> Sorry for the confusion:
>>
>> If a user schedules a single project that has an email post build step 
>> than the email address is resolved automatically by the Active Directory 
>> plugin.
>>
>> I'm having problems with a more complicated build pipeline where the 
>> requesting user isn't propagated to a down stream build that has an email 
>> step. I'm attempting to write a groovy script that will set the email 
>> recipients to the requester of the top level build. I've managed to look up 
>> the user ID from the UserIdCause of the top level build, but I haven't 
>> found a way to resolve an email address from that user id.
>>
>> I hope that's more clear now :).
>>
>>
>> On Tuesday, 11 March 2014 11:33:47 UTC-7, slide wrote:
>>>
>>> You could use the mailmap-resolver-plugin, but I may be missing 
>>> something because there seems to be a discrepancy with what you are saying. 
>>> First you need to look up the user's email address from their user ID, but 
>>> then you say you are getting email addresses from Active Directory? Can you 
>>> clarify.
>>>
>>> Thanks,
>>>
>>> slide
>>>
>>>
>>> On Tue, Mar 11, 2014 at 11:24 AM, Stuart Rowe wrote:
>>>
>>>> Hi, does anyone know of a way to look up a user's email address from 
>>>> their user ID? I can't make the assumption that the email is "
>>>> use...@company.com" because I know this isn't always the case.
>>>>
>>>> We're using the Active Directory plugin for security which is where the 
>>>> email addresses for users are coming from. I need to manually add the 
>>>> requester to the recipient list because this doesn't seem to be propagated 
>>>> by BuildFlow FlowCauses. The relevant parts of build pipeline in this case 
>>>> is:
>>>>
>>>> BuildFlow project A (scheduled by the logged in user) --> Build Flow 
>>>> project B --> Free Style Project with an Editable Email Notification post 
>>>> build step.
>>>>
>>>> Thanks in advance, 
>>>>
>>>> Stuart
>>>>
>>>> -- 
>>>> 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.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Website: http://earl-of-code.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-use...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


Re: [Email-ext] Resolving email address from Cause.UserIdCause

2014-03-11 Thread Stuart Rowe
Sorry for the confusion:

If a user schedules a single project that has an email post build step than 
the email address is resolved automatically by the Active Directory plugin.

I'm having problems with a more complicated build pipeline where the 
requesting user isn't propagated to a down stream build that has an email 
step. I'm attempting to write a groovy script that will set the email 
recipients to the requester of the top level build. I've managed to look up 
the user ID from the UserIdCause of the top level build, but I haven't 
found a way to resolve an email address from that user id.

I hope that's more clear now :).


On Tuesday, 11 March 2014 11:33:47 UTC-7, slide wrote:
>
> You could use the mailmap-resolver-plugin, but I may be missing something 
> because there seems to be a discrepancy with what you are saying. First you 
> need to look up the user's email address from their user ID, but then you 
> say you are getting email addresses from Active Directory? Can you clarify.
>
> Thanks,
>
> slide
>
>
> On Tue, Mar 11, 2014 at 11:24 AM, Stuart Rowe 
> > wrote:
>
>> Hi, does anyone know of a way to look up a user's email address from 
>> their user ID? I can't make the assumption that the email is "
>> use...@company.com " because I know this isn't always the 
>> case.
>>
>> We're using the Active Directory plugin for security which is where the 
>> email addresses for users are coming from. I need to manually add the 
>> requester to the recipient list because this doesn't seem to be propagated 
>> by BuildFlow FlowCauses. The relevant parts of build pipeline in this case 
>> is:
>>
>> BuildFlow project A (scheduled by the logged in user) --> Build Flow 
>> project B --> Free Style Project with an Editable Email Notification post 
>> build step.
>>
>> Thanks in advance, 
>>
>> Stuart
>>
>> -- 
>> 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 .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Website: http://earl-of-code.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.


[Email-ext] Resolving email address from Cause.UserIdCause

2014-03-11 Thread Stuart Rowe
Hi, does anyone know of a way to look up a user's email address from their 
user ID? I can't make the assumption that the email is "use...@company.com" 
because I know this isn't always the case.

We're using the Active Directory plugin for security which is where the 
email addresses for users are coming from. I need to manually add the 
requester to the recipient list because this doesn't seem to be propagated 
by BuildFlow FlowCauses. The relevant parts of build pipeline in this case 
is:

BuildFlow project A (scheduled by the logged in user) --> Build Flow 
project B --> Free Style Project with an Editable Email Notification post 
build step.

Thanks in advance, 

Stuart

-- 
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: For loop in the Jenkins build flow

2014-02-26 Thread Stuart Rowe
parallel() can take a list/map of closures

you will want to do this:

// construct and collect closures for LATER execution
buildClosures = []
for (int i=1; i<100; i++) {
def curClosure = {
build("a", STEP:i)
}
buildClosures.add(curClosure)
}

// execute the closures in buildClosures in parallel
parallel(buildClosures)


On Saturday, 22 February 2014 02:01:32 UTC-8, dev123 wrote:
>
> Is it possible to create a for loop in the jenkins build flow plugin DSL? 
> Currently I have:
>
> parallel (
> { build( "a", STEP: 1) },
> { build( "a", STEP: 2 ) },
> { build( "a", STEP: 3 ) }
> )
>
> Which I need to scale to e.g. 100 parallel executions. Therefore I need to 
> be able to do something like:
>
> parallel (
>
>  for (int i=1; 1<100; i++) {
>   { build( "a", STEP: i) }
> }
> )
>
> But that gives an error.
>

-- 
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/groups/opt_out.


Calling an external groovy script from BuildFlow DSL

2014-02-25 Thread Stuart Rowe
The BuildFlow DSL for some of my projects has become pretty complex and so 
I want to store the meat of the script in an external script. The BuildFlow 
DSL would then just be responsible for calling that script and setting up 
bindings if necessary.

The advantages of this:
1) For debugging orchestration, I can write functions that simulate what 
build() and parallel() do by just printing out the project and parameter 
being executed
2) I don't have to worry about using characters that will break the entire 
config.xml (<,>,&, etc.)
3) I can edit the script without having to reload jenkins configuration 
from disk. 

The two open questions I have:
1) Where to store the external script? In the same directory as the 
config.xml would be ideal IMO, but how can I can get a reference to this? 
Or is there a better place for it?
2) If the bindings for BuildFlow won't be automatically available to the 
external script if I call evaluate(new File("path\to\my\script.grooy")), 
how can I accomplish this?

Thanks,
Stuart

-- 
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/groups/opt_out.


Re: Does the NodeLabelParameter plugin support more than one Label parameter in a project?

2014-02-04 Thread Stuart Rowe
thanks for the reply Mark - that is one solution I could use as a last
resort. I was hoping that the plugin would be doing that boolean expression
internally for each label parameter.

I've pulled the source from github - maybe I can find a solution.


On Tue, Feb 4, 2014 at 11:46 AM, Marc MacIntyre wrote:

> Pass a boolean expression: (A&&y)
>
>
> On Tue, Feb 4, 2014 at 11:30 AM, Stuart Rowe  wrote:
>
>> In my situation I have build machines divided into two categories: A and
>> B. The nodes for each machine are labelled accordingly.
>>
>> I also have platforms associated with each machine (one or more of x, y,
>> z). These are also included in the labels for each node.
>>
>> I would like to set up a project with two label parameters machineType
>> and platform so that a node is selected that has a label matching
>> machineType AND platform. As far as I can tell, the NodeLabelParameter
>> plugin only attempts to match at least one label before selecting a node.
>>
>> Is this the expected behavior?
>>
>>
>>  --
>> 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/groups/opt_out.
>>
>
>
>
> --
> Marc MacIntyre
>
> --
> 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/PI5iFT0VgnU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/groups/opt_out.


Does the NodeLabelParameter plugin support more than one Label parameter in a project?

2014-02-04 Thread Stuart Rowe
In my situation I have build machines divided into two categories: A and B. 
The nodes for each machine are labelled accordingly.

I also have platforms associated with each machine (one or more of x, y, 
z). These are also included in the labels for each node.

I would like to set up a project with two label parameters machineType and 
platform so that a node is selected that has a label matching machineType 
AND platform. As far as I can tell, the NodeLabelParameter plugin only 
attempts to match at least one label before selecting a node.

Is this the expected behavior?


-- 
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/groups/opt_out.