Save variables in env singleton

2017-04-03 Thread kodstark
Hi,

I'm using env singleton to store variables to be used at later stage in 
same pipeline. It is working nice but documentation about env is confusing. 

1) 
https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin 
- Don’t: Set environment variables with env global variable
2) 
https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-withenv-code-set-environment-variables
 
- See the documentation for the env singleton for more information on 
environment variables.

It looks to me that env is a singleton to a single build - not a singleton 
to Jenkins instance. I see an point that withEnv is preferred in some 
places but saying don't use env without explaining why is confusing. 

Regards

Kamil 
  

-- 
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/33b4a118-4b92-41cc-9b59-8ef70ff11d68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it actually possible to trigger pipeline job without Jenkinsfile by notifyCommit http-query?

2017-03-29 Thread kodstark
Actually I got that working - when pipeline completes first time then it 
will be executed via notifyCommit?url service

-- 
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/046fd94a-e575-471b-b5d1-099524d33fdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it actually possible to trigger pipeline job without Jenkinsfile by notifyCommit http-query?

2017-03-29 Thread kodstark
I found this issue to when running Git Plugin 3.1.0, Pipeline Plugin 2.5 - 
I'm doing checkout inside shared library which runs checkout in a loop 
according to config. However link git/notifyCommit?url=... gives me 
response "

No Git consumers using SCM API plugin for"


On Monday, 16 January 2017 13:33:09 UTC, alexand...@gmail.com wrote:
>
> Using Jenkins Pipeline there is no longer Source Code Management html-UI 
> section at job configuration (for a pipeline job checkout is handled the 
> pipeline script of the job).
>
> I am trying to trigger a test job by 'notifyCommit' http-query (using 
> curl):
> curl "http:///git/notifyCommit?url=ssh://git@<
> git-server-address>//" 
> 
>
> This http-query successfully triggers my FreeStyle jobs with Source Code 
> Management configured (via job UI) appropriately.
> But any of my variants of Pipeline jobs containing 'git' or 'checkout scm' 
> are not triggered by this http-query.
>
> Here are some of my Pipeline job scripts I tried to set up 
> 'notifyCommit'-triggering:
> node () {
>   git url: 'ssh://git@//', branch: 
> 'master', credentialsId: ''
> }
>  this variant I borrowed from:
> https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md
> (see 'Creating a Simple Pipeline' section -> 'Understanding syntax' 
> sub-section)
> and modified in accordance with: 
> https://jenkins.io/doc/pipeline/steps/git/
>
> node () {
>   checkout(
> [  $class: 'GitSCM',
>userRemoteConfigs: [[url: 
> 'ssh://git@//']],
>credentialsId: ''  ]
>   )
> }
>  this variant I borrowed from:
> https://github.com/jenkinsci/workflow-scm-step-plugin/blob/master/README.md
> (see 'Generic SCM step' section)
>
> At html-UI of pipeline jobs I switched on 'Poll SCM' (without schedule).
> I tried with 'Poll SCM' unchecked also.
> For 'git' pipeline step I tried also 'poll' false and true values.
> Job HTML-UI setting 'Ignore post-commit hooks' was unchecked during all my 
> tries.
> Also I didn't use '$class: IgnoreNotifyCommit'.
> On the other hand I successfully configured a pipeline job to be triggered 
> via 'Trigger bulds remotely' set up.
>
> The readme I already referred few lines above (see link below) says that 
> it's possible to trigger pipeline job via 'notifyCommit':
> https://github.com/jenkinsci/workflow-scm-step-plugin/blob/master/README.md
> (see 'Features' section -> 'Polling' sub-section)
>  but there are no complete examples and no clarifications on several 
> aspects of such set up.
> Particularly it's unclear if both variants (with Jenkinsfile & with job 
> html-UI pipeline script) can be triggered via 'notifyCommit' http-query.
>
> Am I miss something?
> Can it be that my 'Jenkins' + 'Pipeline Plugin' + 'Git plugin' versions 
> have a bug?
> For now I use Jenkins 2.8, Pipeline Plugin 2.4, Git Plugin 3.0.0 .
>
>
> Kind regards
> Alexander Ites
>

-- 
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/7b6cc5e8-e695-4bde-b66b-62b60b425564%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pipeline: limit concurrency of parallel jobs with lock or in other way

2017-03-28 Thread kodstark
Hi,

I'm not able to find how to limit concurrency of parallel step. I know that 
one option is to use jenkins node label but it is too heavy. 

It thought that by design parallel should work with lock but locks allows 
to give quantity only with label - so I tried this:


for (int idx = 0; idx < 3; idx++)
{
lock(resource: 'parallel_test_' + idx + '_' + config.mylabel, label: 
'parallel_test_' + config.mylabel)
{
echo 'Create lock ' + 'parallel_test_' + idx + '_' + config.
ansibleEnvLabel
}
}

for (int testIdx = 0; testIdx < stageStep.tests.size(); testIdx++)
{
def test = steps.tests[testIdx]
def testFullName = "${Parallel_${test.testName}_${testIdx}"
parallelJobsToExecute[testFullName] = {
lock(label: 'parallel_test_' + config.mylabel, quantity: 1)
{
node('ansible')
{ 



However this doesn't work because first loop cannot create lock with 
resource name and label together. I'm getting this error:

java.lang.IllegalArgumentException: Label and resource name cannot be specified 
simultaneously.

Is there a achieve that ?

Kamil 



-- 
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/a18e1579-0ce2-40df-b4dc-5d375df4b7e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Scripted pipeline with reentrant lock vs deadlock

2017-03-28 Thread kodstark
Hi,

I've looked if anybody discussed reentrant lock with jenkins pipeline but 
couldn't find anything at this group.

Consider this scenario when I want to have pipelines ALL, DEPLOY, TESTS. 
Last two pipelines have around 20 lines and I don't want to repeat that in 
ALL so ALL would just call those two pipelines - however I'm getting 
deadlock here.

ALL
lock('env_lock_name')
{
stage ('DEPLOY')
{
build job: 'DEPLOY'
}

stage ('TEST')
{
build job: 'TEST'
}
}

DEPLOY:
lock('env_lock_name')
{
stage ('DEPLOY')
{
echo 'DEPLOY'
}
}

TEST:
lock('env_lock_name')
{
stage ('TEST')
{
echo 'TEST'
}
}

Pipelines TEST and DEPLOY can be executed standalone so they need lock too.

I want to have lock in 'ALL' pipeline to ensure that nothing will get 
executed between DEPLOY and TEST at this env.

Logic of reentrant lock would resolve it. Do you have something similar 
already at your roadmap? Any ideas what would be a 'workaround' for now?

I could use shared library to move deploy there as a function and call it 
from two places but I would like to have history of deployments in one 
place under DEPLOY pipeline history.

Regards

Kamil


-- 
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/b326db40-9896-4a9c-958d-17989be953a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.