Groovy output from println statements, where is it?

2020-09-17 Thread Kenny Cason
I have some groovy code in a Jenkins pipeline that populates a dropdown 
chooser, *sometimes*.  The code calls a shell script which outputs a JSON 
string which is then parsed by Groovy to return just a list found in the 
JSON. When I run it standalone outside of Jenkins it *always *produces the 
correct JSON output I expect. When I run it inside Jenkins it works 
randomly.

I'd like to see the debug println output when the code doesn't work. 
Normally I would expect this to be in the Jenkins build console but there 
is no output from Groovy found there.

Does Groovy send sysout somewhere else, or can I force it to send it to a 
log?

(I would post the code but it's on a different server) :-(

-- 
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/9bcb5af6-5c16-456a-aca3-6bcd8567182cn%40googlegroups.com.


Unable to trigger Jenkins job using API Token command-line curl

2020-09-17 Thread Mohtashim S


My requirement is to trigger(build) a jenkins job using command-line which 
I will invoke using ansible.

I'm following the instructions on this stackoverflow link 

.

I followed the below steps but Unfortunately the build does not get 
triggered.

Step 1: I logged in Jenkins portal https://myjenkins.com:9043 using my user 
id user114 which is also the Jenkins administrator.

I then created API-token for my user id which 
is 118f32aa48601c136d29y11f3dd0e107f5.

Step 2: I then selected Trigger Build Remotely option for job5 and gave the 
token name as 118f32aa48601c136d29y11f3dd0e107f5

Step 3: I then created Jenkins-Crumb using the below command:
curl -s -k 
'https://user114:118f32aa48601c136d29y11f3dd0e10...@myjenkins.com:9043/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
 
Jenkins-Crumb:5196c183ad95cf3c0482873e34236f3b78ab628ecba968086cd19s7430016a4e

Then i tried the below commands with the intention of triggering the build 
for job5 but none of them triggered my Jenkins build.

Attemp 1:
$ curl -I -k -X POST 
https://user114:118f32aa48601c136d29y11f3dd0e10...@myjenkins.com:9043/job/job5/build
 
-H 
"Jenkins-Crumb:5196c183ad95cf3c0482873e34236f3b78ab628ecba968086cd19s7430016a4e"
 
HTTP/1.1 400 Bad Request X-Content-Type-Options: nosniff Cache-Control: 
must-revalidate,no-cache,no-store Content-Type: 
text/html;charset=iso-8859-1 Content-Length: 481 Server: Jetty(NOTHING) 

Attempt 2:
$ curl -k -X POST 
https://user114:118f32aa48601c136d29y11f3dd0e10...@myjenkins.com:9043/job/job5/build
 
-H 
"Jenkins-Crumb:5196c183ad95cf3c0482873e34236f3b78ab628ecba968086cd19s7430016a4e"
 
   Error 400 Nothing is 
submitted  HTTP ERROR 400 Nothing is 
submitted  URI:/job/job5/build 
STATUS:400 MESSAGE:Nothing is 
submitted SERVLET:Stapler  
http://eclipse.org/jetty;>Powered by Jetty:// NOTHING 
 

Attempt 3:
$ curl -k -X POST 
https://user114:118f32aa48601c136d29y11f3dd0e10...@myjenkins.com:9043/job/job5/build?token=118f32aa48601c136d29y11f3dd0e107f5
 
-H 
"Jenkins-Crumb:5196c183ad95cf3c0482873e34236f3b78ab628ecba968086cd19s7430016a4e"
 
   Error 400 This page expects a 
form submission  HTTP ERROR 400 This page expects 
a form submission  
URI:/job/job5/build 
STATUS:400 MESSAGE:This page 
expects a form submission 
SERVLET:Stapler  http://eclipse.org/jetty;>Powered by Jetty:// NOTHING 
  

Further, I also intend to pass parameters to this jenkins job which i dont 
know how-to.

Can you please suggest ?

-- 
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/f901fe2b-a07c-408b-ab3f-acbfa822d8f4n%40googlegroups.com.


Re: Suppressing certain builds

2020-09-17 Thread jeremy mordkoff

node { 
 stage("checkout") { 
   checkout scm 
   result = sh (script: "git log -1 | grep bump", returnStatus: true) 
   if (result == 0) { 
  println("CI bump commit...skipping build")
  currentBuild.result = 'NOT_BUILT'
  # can I just return here ? exit 0? 
   }
 }
 stage("build") { 


On Thursday, September 17, 2020 at 3:30:01 PM UTC-4 zil...@gmail.com wrote:

> Can you give a simple example?
>
> On Thursday, September 17, 2020 at 12:17:36 PM UTC-4 jeremy@riftio.com 
> wrote:
>
>> I use scripted pipelines
>>
>> I would like certain builds to abort early. (1) if it is just a branch 
>> creation event, (2) if the commit message is "bump" and (3) if the only 
>> change was in certain submodules. 
>>
>> I think I know all the pieces to make this work -- I can write a tool 
>> that could determine if a build was needed or not. What I don't know is 
>> what is the best way to abort the pipeline. Do I set the 
>> currentBuild.status and return? Or do I need to wrap all of the subsequent 
>> stages in an if?
>>
>

-- 
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/d4bf76d4-c7cb-406c-a66c-8ab9dd7d6ab4n%40googlegroups.com.


Re: how to build on branch creation but not build on other scm event/commit?

2020-09-17 Thread Tim Black
Thanks Jeremy. Our developers already have control of their projects' 
branches' Jenkinsfiles so they can define whatever triggers/schedule they 
want. If I were going to hack this, I'd probably prefer to do the opposite 
of what you're recommending. Since git scanning is a wheel already invented 
many times, I'd rather NOT "Suppress Automatic SCM Triggering", but modify 
our pipelines (Declarative Jenkinsfile + loaded groovy file(s)) to check 
the "build cause" and act accordingly. Ultimately, we're likely to need 
this kind of sophistication anyway, since some build causes ( e.g. Branch 
Discovery, PR, commit, etc) may need special behavior. Ultimately 
ultimately, we'll have more build capacity and will be able to support 
per-commit builds, so perhaps some of this is temporary.

We're using Bitbucket On Prem, FWIW, and soon I will be implementing 
various Jenkins-Bitbucket integrations. Currently we're still just using 
Jenkins git plugin as BranchSource for our multibranch pipeline jobs. 
Perhaps once I switch us over to using the Bitbucket Server Integration 
plugin , 
a more elegant solution to this fine control over Automatic SCM Triggering 
will become clear.

Cheers.

On Thursday, September 17, 2020 at 9:12:17 AM UTC-7 jeremy@riftio.com 
wrote:

> You could leave the Automatic triggering suppressed and write a tool to 
> scan your GIT repo looking for new branches and trigger the build via an 
> API call when a new branch is found. Sounds like you might need such a tool 
> anyway so that developers could schedule builds. 
>
> On Thursday, September 17, 2020 at 12:59:27 AM UTC-4 timb...@gmail.com 
> wrote:
>
>> 1. I have a multibranch pipeline job that takes 30min to run, has a lot 
>> of branches, and my company is still at the earlier stages of devops 
>> transformation, so with our current infrastructure we do not want to 
>> trigger a build every commit.
>>
>> 2. Our job pipeline uses parameters heavily, so I would also like to 
>> automatically build each branch on branch creation/detection. 
>>
>> How do I achieve the above 2 requirements?
>>
>> Using git scm/plugin/branchsource, if I set (or clear) "Suppress 
>> Automatic SCM triggering", I get only one of the two requirements 
>> fulfilled: setting it suppresses ALL automatic triggering, not providing 2. 
>> Clearing it satisfies 2, automatically triggering a build on branch 
>> discovery, but also builds every commit which we don't want.
>>
>> In my research I have found the basic branch build strategies plugin 
>> ,
>>  
>> and while it provides some great sophisticated control over what branches 
>> build when, in terms of ensuring the job is built on branch creation, it 
>> seems to only provide added suppression.
>>
>> Any suggestions would be welcome. 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/bf3c640f-2cbf-4f20-8539-81ea8d1b530en%40googlegroups.com.


Re: Suppressing certain builds

2020-09-17 Thread zil...@gmail.com
Can you give a simple example?

On Thursday, September 17, 2020 at 12:17:36 PM UTC-4 jeremy@riftio.com 
wrote:

> I use scripted pipelines
>
> I would like certain builds to abort early. (1) if it is just a branch 
> creation event, (2) if the commit message is "bump" and (3) if the only 
> change was in certain submodules. 
>
> I think I know all the pieces to make this work -- I can write a tool that 
> could determine if a build was needed or not. What I don't know is what is 
> the best way to abort the pipeline. Do I set the currentBuild.status and 
> return? Or do I need to wrap all of the subsequent stages in an if?
>

-- 
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/b06772a2-9f7c-4007-a355-c4ec5c8033f0n%40googlegroups.com.


Re: How to refer to an object in a shared library?

2020-09-17 Thread zil...@gmail.com
I use this extensibly in my pipelines
https://www.jenkins.io/doc/book/pipeline/shared-libraries/

For example, I can have the following files
/path/src/com/company/deployment/script1.groovy
/path/src/com/company/deployment/script2.groovy

Now I want both scripts to refer to a common object in
/path/src/com/company/deployment/common.groovy

For example

common.groovy
package com.company.deployment.common
class MyClass {
}

script1.groovy
package com.company.deployment
import com.company.deployment.common
MyClass mc = new MyClass()

scrpt2.groovy
package com.company.deployment
import com.company.deployment.common
MyClass mc = new MyClass()

But I get the following with I try to run either script1 or script2
unable to resolve class MyClass

What else do I need to do?
On Thursday, September 17, 2020 at 3:22:46 PM UTC-4 zil...@gmail.com wrote:

> I use this extensibly in my pipelines
> https://www.jenkins.io/doc/book/pipeline/shared-libraries/
>
> For example, I can have the following files
> /path/src/com/company/deployment/script1.groovy
> /path/src/com/company/deployment/script2.groovy
>
> Now I want both scripts to refer to a common object in
> /path/src/com/company/deployment/common.groovy
>
> For example
>
> common.groovy
> package com.company.deployment.common
> class MyClass {
> }
>
> script1.groovy
> package com.company.deployment
> import com.company.deployment.common
> MyClass mc = new MyClass()
>
> scrpt2.groovy
> package com.company.deployment
> import com.company.deployment.common
> MyClass mc = new MyClass()
>
>
>

-- 
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/172ca56b-24a7-4e3a-bf37-1aa153793ddan%40googlegroups.com.


How to refer to an object in a shared library?

2020-09-17 Thread zil...@gmail.com
I use this extensibly in my pipelines
https://www.jenkins.io/doc/book/pipeline/shared-libraries/

For example, I can have the following files
/path/src/com/company/deployment/script1.groovy
/path/src/com/company/deployment/script2.groovy

Now I want both scripts to refer to a common object in
/path/src/com/company/deployment/common.groovy

For example

common.groovy
package com.company.deployment.common
class MyClass {
}

script1.groovy
package com.company.deployment
import com.company.deployment.common
MyClass mc = new MyClass()

scrpt2.groovy
package com.company.deployment
import com.company.deployment.common
MyClass mc = new MyClass()


-- 
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/a4fee179-0f21-4827-bae4-8f6a457cf2den%40googlegroups.com.


FIXED: Re: How to restore Safe HTML for Parameter Separator descriptions?

2020-09-17 Thread G Dameron
JENKINS-56277  was 
opened in Feb 2019 and fixed in version 1.3 (released August 2020). Many 
thanks to Piotr PaczyƄski.

On Wednesday, January 16, 2019 at 12:42:55 PM UTC-7 G Dameron wrote:

> Back in 1.596, I used Safe HTML for all build parameter descriptions, so 
> that the user prompt/guidance under each parameter really "popped" for my 
> large-ish user base.
>
> Safe HTML for parameter descriptions has eroded over time with 
> security-related changes. Under 2.89, the Node and Extended Choice 
> parameter types stopped honoring Safe HTML descriptions. As a workaround, I 
> inserted invisible Parameter Separators and transferred the Safe HTML from 
> the offending parameter's description to the Separator's. It looked and 
> worked great.
>
> Then came 2.150. Somewhere along the way, even the lowly Parameter 
> Separator stopped supporting Safe HTML descriptions.
>
> Is there, perhaps, a -D switch I could add to the java options to bring it 
> back, even if only for the Parameter Separator?
>

-- 
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/a9b71715-78e3-42f4-b0b4-b5e7210d076dn%40googlegroups.com.


Suppressing certain builds

2020-09-17 Thread jeremy mordkoff
I use scripted pipelines

I would like certain builds to abort early. (1) if it is just a branch 
creation event, (2) if the commit message is "bump" and (3) if the only 
change was in certain submodules. 

I think I know all the pieces to make this work -- I can write a tool that 
could determine if a build was needed or not. What I don't know is what is 
the best way to abort the pipeline. Do I set the currentBuild.status and 
return? Or do I need to wrap all of the subsequent stages in an if?

-- 
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/5a5fa1aa-23ae-4515-9695-b2888f43fec1n%40googlegroups.com.


Re: how to build on branch creation but not build on other scm event/commit?

2020-09-17 Thread jeremy mordkoff
You could leave the Automatic triggering suppressed and write a tool to 
scan your GIT repo looking for new branches and trigger the build via an 
API call when a new branch is found. Sounds like you might need such a tool 
anyway so that developers could schedule builds. 

On Thursday, September 17, 2020 at 12:59:27 AM UTC-4 timb...@gmail.com 
wrote:

> 1. I have a multibranch pipeline job that takes 30min to run, has a lot of 
> branches, and my company is still at the earlier stages of devops 
> transformation, so with our current infrastructure we do not want to 
> trigger a build every commit.
>
> 2. Our job pipeline uses parameters heavily, so I would also like to 
> automatically build each branch on branch creation/detection. 
>
> How do I achieve the above 2 requirements?
>
> Using git scm/plugin/branchsource, if I set (or clear) "Suppress Automatic 
> SCM triggering", I get only one of the two requirements fulfilled: setting 
> it suppresses ALL automatic triggering, not providing 2. Clearing it 
> satisfies 2, automatically triggering a build on branch discovery, but also 
> builds every commit which we don't want.
>
> In my research I have found the basic branch build strategies plugin 
> ,
>  
> and while it provides some great sophisticated control over what branches 
> build when, in terms of ensuring the job is built on branch creation, it 
> seems to only provide added suppression.
>
> Any suggestions would be welcome. 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/ac468efa-99d3-458e-9114-3800ac5484d5n%40googlegroups.com.