Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread David Karr
On Wed, Sep 22, 2021 at 8:16 AM 'Björn Pedersen' via Jenkins Users <
jenkinsci-users@googlegroups.com> wrote:

>
>
>> I'm not familiar with the archive process. If you could provide me some
>> quick links for information, that would be useful. I'll also ask our
>> internal ops team.
>>
>>
>
> Archiving is not something  special, it's a standard feature.
> in a scripted pipeline:
>
> archiveArtifacts artifacts: '**/*.log'
> (just use the script builder for more help)
>
> link to:
> $BUILD_URL/artifact//
>

That "our local path" thing is not clear to me. What exactly would that
be?  If the file I create is in the root directory of the workspace , would
that "local path" be empty?

-- 
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/CAA5t8Vr6RQHNW2NCKBdkAjqgNt3Ra1pN01LU6KsXbk50CVcwkA%40mail.gmail.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread David Karr
On Wed, Sep 22, 2021 at 7:29 AM 'Björn Pedersen' via Jenkins Users <
jenkinsci-users@googlegroups.com> wrote:

>
>
> db...@cloudbees.com schrieb am Mittwoch, 22. September 2021 um 14:54:48
> UTC+2:
>
>> On Mon, Sep 13, 2021 at 5:49 PM Jerome Godbout 
>> wrote:
>>
>>> Humm, that would be hard and security unwise. The executing node path
>>> aren't available to the web.
>>
>>
>> They are in the case of workspace files (to users with appropriate
>> permissions).
>>
>> I think the problem is that it's difficult to obtain the pipeline node ID
>> for the `node` step allocating the workspace.
>>
>> Between the BUILD_URL and WORKSPACE (the prefix of the path to remove),
>> the rest should be known.
>>
>
> I the another problem that is more important (at least in general): The
> workspace is not persisted as part of the job, instead it
>  may well get reused  and/or cleaned once the job is finished. So clicking
> the link on an older job may well get you the file from
> a newer run. That's why I really recommend to just archive this file as
> artifact and use the artifact link( which is stable and easier to construct)
> instead.
> Björn
>

I'm not familiar with the archive process. If you could provide me some
quick links for information, that would be useful. I'll also ask our
internal ops team.

-- 
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/CAA5t8VqFQ2LP2B9KZ%3D%3DShbWXLuG347Vi%2B5FBPRN5ROOY13G_qg%40mail.gmail.com.


Re: Can vars scripts reference variables defined in a higher scope?

2021-09-16 Thread David Karr
I've managed to implement something that is effectively the same.  I 
realized that I can define a class in "src" that is just a static data 
container and can be accessed from any of the "vars" scripts.

On Thursday, September 16, 2021 at 1:21:10 PM UTC-7 David Karr wrote:

>
> I work on a somewhat complicated build process using Jenkins scripted 
> pipeline, where the Jenkinsfile is very small, but it imports a large 
> shared library, sets some application-specific properties, and then calls a 
> top-level function in the "vars" section of the shared library.
>
> The top-level function is pretty complicated, and it calls a bunch of 
> other "var" functions.  Data is passed to those functions through "env." 
> vars, and function parameters.
>
> I am working on some changes to one of the lower-level functions, where it 
> will reference a couple of "statically-defined" map objects that specify 
> some metadata about build steps.
>
> Initially, I simply defined those maps inside the "call()" function in the 
> "vars" file.  That does work.  However, I see that there is more than one 
> "vars" file that needs to reference those maps.
>
> It would make sense if I could move these map definitions to the top-level 
> "vars" file, I assume right inside the "call()" function (or somewhere 
> else, if that makes sense) and then reference them inside the "vars" 
> functions that need that data.
>
> If these were scalar values, I would just set "env. = 
> " in the top-level "vars" file, inside the "call()" function, and 
> then reference that environment variable in the lower-level "vars" file.  
> Can I set a Map object into environment variables?  I wouldn't think it 
> would allow that.
>
> I technically could simply reference the variable name in the top-level 
> "vars" function, and pass it down through the layers, but that gets messy.  
> I'd prefer to reference these maps like "static" variables (conceptually if 
> not in actuality) in the lower-level "vars" file.
>
> I have browsed the documentation, but I haven't seen an obvious way to do 
> this.
>

-- 
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/222db998-b989-4528-afc8-c2c8e16152c7n%40googlegroups.com.


Can vars scripts reference variables defined in a higher scope?

2021-09-16 Thread David Karr

I work on a somewhat complicated build process using Jenkins scripted 
pipeline, where the Jenkinsfile is very small, but it imports a large 
shared library, sets some application-specific properties, and then calls a 
top-level function in the "vars" section of the shared library.

The top-level function is pretty complicated, and it calls a bunch of other 
"var" functions.  Data is passed to those functions through "env." vars, 
and function parameters.

I am working on some changes to one of the lower-level functions, where it 
will reference a couple of "statically-defined" map objects that specify 
some metadata about build steps.

Initially, I simply defined those maps inside the "call()" function in the 
"vars" file.  That does work.  However, I see that there is more than one 
"vars" file that needs to reference those maps.

It would make sense if I could move these map definitions to the top-level 
"vars" file, I assume right inside the "call()" function (or somewhere 
else, if that makes sense) and then reference them inside the "vars" 
functions that need that data.

If these were scalar values, I would just set "env. = 
" in the top-level "vars" file, inside the "call()" function, and 
then reference that environment variable in the lower-level "vars" file.  
Can I set a Map object into environment variables?  I wouldn't think it 
would allow that.

I technically could simply reference the variable name in the top-level 
"vars" function, and pass it down through the layers, but that gets messy.  
I'd prefer to reference these maps like "static" variables (conceptually if 
not in actuality) in the lower-level "vars" file.

I have browsed the documentation, but I haven't seen an obvious way to do 
this.

-- 
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/181c2122-ddad-4f88-9f01-018cc89f64b6n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-13 Thread David Karr
Thanks for the reply, but I think you've misunderstood the problem.  
Getting, using, and publishing the filesystem path to the file is not a 
problem. What I need to do is create a functional url to that file, which I 
can print in the Jenkins build output, which a user can click to get to 
that file.

On Monday, September 13, 2021 at 6:40:56 AM UTC-7 jerome.god...@gmail.com 
wrote:

> Some helper I made for my scripted:
>
> Path conversion:
> *def ToWindowsPath(path) {*
> *return path.replace("/", "\\");*
> *}*
>
> *def ToUnixPath(path) {*
> *return path.replace("\\","/");*
> *}*
>
> *def ToNativePath(path) {*
> *if(isUnix()) {*
> *return ToUnixPath(path);*
> * }*
> *return ToWindowsPath(path);*
> *}*
>
> *def RemoveLastChar(str) {*
> *return str.substring(0, str.length() - 1);*
> *}*
>
> *def RemoveFirstChar(str) {*
> *return str.substring(1, str.length());*
> *}*
>
> Joining path part:
> *def PathJoin(path1, path2) {*
> *String p1 = ToUnixPath(path1);*
> *String p2 = ToUnixPath(path2);*
> *if(p1.length() > 1 && p1.endsWith("/")) {*
> *p1 = RemoveLastChar(p1);*
> * }*
> *if(p2.startsWith("/")) {*
> *p2 = RemoveFirstChar(p2);*
> * }*
> *if(p1 == "/") {*
> *return p1 + p2;*
> * }*
> *if(p1.length() == 0) {*
> *return p2;*
> * }*
> *if(p2.length() == 0) {*
> *return p1;*
> * }*
> *return p1 + "/" + p2;*
> *}*
>
> *def PathsJoin(paths) {*
> *String result_path = "";*
> *if(paths instanceof List && paths.size() > 0) {*
> *result_path = paths[0];*
> *for(int i = 1; i < paths.size(); ++i) {*
> *result_path = PathJoin(result_path, paths[i]);*
> * }*
> * }*
> *return result_path;*
> *}*
>
> And to get the workspace root, you can use the pwd command, when the 
> script start onto the node, the current dir is the workspace, so you could 
> save it into a var with pwd command at the beginning. After use the path 
> join above to recreate some path.
>
> https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#pwd-determine-current-directory
>
>
> On Monday, September 13, 2021 at 2:30:18 AM UTC-4 ice...@googlemail.com 
> wrote:
>
>> Hi,
>>
>> no, not really. Especially as  workspaces typically are reused between 
>> jobs such an URL would be at leas open to surprise.  Best practice is to 
>> archive such files (log output, generated files. ) as  artifacts to get 
>> persistence. 
>>
>> Björn
>>
>> davidmic...@gmail.com schrieb am Freitag, 10. September 2021 um 22:09:36 
>> UTC+2:
>>
>>> I do notice that my build has a "BUILD_URL" var in the environment, so 
>>> that gives me the "prefix" of the url, but the url to the file in the 
>>> workspace has pieces like the following after the BUILD_URL value: 
>>> "/execution/node/22/ws/". I don't see anything else in the environment that 
>>> can help me construct that part of the url.
>>>
>>> On Friday, September 10, 2021 at 9:22:16 AM UTC-7 David Karr wrote:
>>>
>>>> When a Jenkins build completes, I can navigate to "Workspaces" to 
>>>> manually inspect files in the workspace.  While I'm navigating that tree, 
>>>> and viewing specific files, I can see that the current browser url goes 
>>>> directly to that point in the tree, and to the specific file I am viewing.
>>>>
>>>> Is there a practical way in a Jenkins scripted pipeline, to CONSTRUCT a 
>>>> url to a file in the workspace so I can print it out in the log, to enable 
>>>> a single click to get to a particular file?
>>>>
>>>

-- 
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/dbd45854-9e8f-402e-9243-29a1181b6257n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-10 Thread David Karr
I do notice that my build has a "BUILD_URL" var in the environment, so that 
gives me the "prefix" of the url, but the url to the file in the workspace 
has pieces like the following after the BUILD_URL value: 
"/execution/node/22/ws/". I don't see anything else in the environment that 
can help me construct that part of the url.

On Friday, September 10, 2021 at 9:22:16 AM UTC-7 David Karr wrote:

> When a Jenkins build completes, I can navigate to "Workspaces" to manually 
> inspect files in the workspace.  While I'm navigating that tree, and 
> viewing specific files, I can see that the current browser url goes 
> directly to that point in the tree, and to the specific file I am viewing.
>
> Is there a practical way in a Jenkins scripted pipeline, to CONSTRUCT a 
> url to a file in the workspace so I can print it out in the log, to enable 
> a single click to get to a particular file?
>

-- 
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/d3dbf8b8-93c0-4194-8311-bac7656b90b6n%40googlegroups.com.


Any way to construct a url to a particular file in the jenkins workspace?

2021-09-10 Thread David Karr
When a Jenkins build completes, I can navigate to "Workspaces" to manually
inspect files in the workspace.  While I'm navigating that tree, and
viewing specific files, I can see that the current browser url goes
directly to that point in the tree, and to the specific file I am viewing.

Is there a practical way in a Jenkins scripted pipeline, to CONSTRUCT a url
to a file in the workspace so I can print it out in the log, to enable a
single click to get to a particular file?

-- 
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/CAA5t8VrTcOF-1AtCS_%3DfnR9hhfQmF%2BSJ8J62pyVtWqJs-neFag%40mail.gmail.com.


Re: how can I iterate a json with a list of objects in a pipeline?

2021-04-19 Thread David Karr
You're missing the most important value of what JsonSlurper (and similar 
tools) provides. There is no reason to iterate maps, and it's important to 
realize that there is no ordering guarantee of map values.

If you want to reference the "issues" property, just reference 
"json.issues". You will need to iterate over the "json.issues" list, and 
each of those objects should be "issue" objects, and if you need to 
reference those particular properties, just reference "issue.type", 
"issue.severity", et cetera.

On Monday, April 19, 2021 at 9:23:27 AM UTC-7 jesusfern...@gmail.com wrote:

> I have a json object which I receive in my jenkins pipeline through a url 
> and I parse it like this:
> ```
> def url = 'http://localhost:8080/job/find_issues/22/cppcheck/all/api/json'
> def json = new JsonSlurper().parseText( new URL(url).text )
>
> ```
>
> Which has this format
> ```
> {
> "_class": "io.jenkins.plugins.analysis.core.restapi.ReportApi",
> "issues": [],
> "size": 100,
> "toString": "- (-): 100 issues (0 duplicates)"
> }
> ```
> which can have a different number of issues inside the `issues` list, each 
> of them having this structure:
> ```
> {
> "addedAt": 0,
> "authorEmail": "-",
> "authorName": "-",
> "baseName": "stat_obj.cpp",
> "category": "",
> "columnEnd": 0,
> "columnStart": 0,
> "commit": "-",
> "description": "",
> "fileName": "D:/Source/Game/objects/stat_obj.cpp",
> "fingerprint": "D2CD3A23FB45D3A1F1C3CB8BE5241602",
> "lineEnd": 5592,
> "lineStart": 5592,
> "message": "Unmatched '('. Configuration: 'DEBUGMAPEXPLORATION'.",
> "moduleName": "",
> "origin": "cppcheck",
> "originName": "CPPCheck",
> "packageName": "-",
> "reference": "19",
> "severity": "HIGH",
> "toString": "D:/Source/Game/objects/stat_obj.cpp(5592,0): syntaxError: : 
> Unmatched '('. Configuration: 'DEBUGMAPEXPLORATION'.",
> "type": "syntaxError"
> }
> ```
> How can I access the Issues list and the iterate through each one of the 
> issues and them through each of the issue keys? 
> I have tried different ways, lastly I have this:
> ```
> for (entry in json) {
> if(entry.key == "issues")
> {
> for (issue in entry.value) {
> entry.value.each{ key, value ->
> if (key == "fileName"){
> errorsList.add(value)
> }
> if (key == "lineStart"){
> errorsList.add(value)
> }
> if (key == "message"){
> errorsList.add(value)
> }
> if (key == "severity"){
> errorsList.add(value)
> }
> if (key == "type"){
> errorsList.add(value)
> }
> def msg = "New ERROR found in static analysis, TYPE OF 
> ERROR ${errorsList[4]}, SEVERITY: ${errorsList[3]}, ERROR MESSAGE: 
> ${errorsList[2]}, FILE ${errorsList[0]} AT LINE: ${errorsList[1]}"
> println msg
> errorsList.clear()
> }
> }
> }
> }
> ```
> But when I call print `msg` I have something like this:
> ```
> 17:13:09  New ERROR found in static analysis, TYPE OF ERROR null, 
> SEVERITY: null, ERROR MESSAGE: null, FILE null AT LINE: null
> ```
> It seems like I am over iterating but I do not get to see where is the 
> mistake...
>

-- 
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/93d32032-bf4d-4889-9377-7c7f1f39d322n%40googlegroups.com.


Re: where do I have to set the sonar-project.properties file to make sonar work in Jenkins?

2020-11-12 Thread David Karr
nsor' skipped because there is
>>>> no related file in current project
>>>> 00:00:04.783  11:26:43.789 DEBUG: 'Analyzer for "php.ini" files'
>>>> skipped because there is no related file in current project
>>>> 00:00:04.783  11:26:43.791 DEBUG: 'Generic Test Executions Report'
>>>> skipped because one of the required properties is missing
>>>> 00:00:04.783  11:26:43.791 DEBUG: 'C++ (Community) XunitSensor' skipped
>>>> because one of the required properties is missing
>>>> 00:00:04.783  11:26:43.791 DEBUG: 'C++ (Community) Unit Test Results
>>>> Import' skipped because there is no related file in current project
>>>> 00:00:04.783  11:26:43.791 DEBUG: Sensors : CSS Rules -> JaCoCo XML
>>>> Report Importer -> C# Properties -> JavaXmlSensor -> VB.NET Properties
>>>> 00:00:04.783  11:26:43.792 INFO: Sensor CSS Rules [cssfamily]
>>>> 00:00:04.783  11:26:43.793 INFO: No CSS, PHP, HTML or VueJS files are
>>>> found in the project. CSS analysis is skipped.
>>>> 00:00:04.783  11:26:43.793 INFO: Sensor CSS Rules [cssfamily] (done) |
>>>> time=1ms
>>>> 00:00:04.783  11:26:43.793 INFO: Sensor JaCoCo XML Report Importer
>>>> [jacoco]
>>>> 00:00:04.783  11:26:43.794 INFO: 'sonar.coverage.jacoco.xmlReportPaths'
>>>> is not defined. Using default locations:
>>>> target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
>>>> 00:00:04.783  11:26:43.795 INFO: No report imported, no coverage
>>>> information will be imported by JaCoCo XML Report Importer
>>>> 00:00:04.783  11:26:43.795 INFO: Sensor JaCoCo XML Report Importer
>>>> [jacoco] (done) | time=2ms
>>>> 00:00:04.783  11:26:43.795 INFO: Sensor C# Properties [csharp]
>>>> 00:00:04.783  11:26:43.795 DEBUG: Project 'Test': Property missing:
>>>> 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for
>>>> this project.
>>>> 00:00:04.783  11:26:43.796 DEBUG: Project 'Test': No Roslyn issues
>>>> reports have been found.
>>>> 00:00:04.783  11:26:43.796 INFO: Sensor C# Properties [csharp] (done) |
>>>> time=1ms
>>>> 00:00:04.783  11:26:43.796 INFO: Sensor JavaXmlSensor [java]
>>>> 00:00:04.783  11:26:43.796 INFO: Sensor JavaXmlSensor [java] (done) |
>>>> time=0ms
>>>> 00:00:04.783  11:26:43.796 INFO: Sensor VB.NET Properties [vbnet]
>>>> 00:00:04.783  11:26:43.797 DEBUG: Project 'Test': Property missing:
>>>> 'sonar.vbnet.analyzer.projectOutPaths'. No protobuf files will be loaded
>>>> for this project.
>>>> 00:00:04.783  11:26:43.797 DEBUG: Project 'Test': No Roslyn issues
>>>> reports have been found.
>>>> 00:00:04.783  11:26:43.797 INFO: Sensor VB.NET Properties [vbnet]
>>>> (done) | time=1ms
>>>> 00:00:04.783  11:26:43.800 INFO: - Run sensors on project
>>>> 00:00:04.783  11:26:43.808 DEBUG: 'Generic Coverage Report' skipped
>>>> because one of the required properties is missing
>>>> 00:00:04.783  11:26:43.808 DEBUG: 'C#' skipped because there is no
>>>> related file in current project
>>>> 00:00:04.783  11:26:43.808 DEBUG: 'C# Tests Coverage Report Import'
>>>> skipped because there is no related file in current project
>>>> 00:00:04.783  11:26:43.808 DEBUG: '[Deprecated] C# Integration Tests
>>>> Coverage Report Import' skipped because there is no related file in current
>>>> project
>>>> 00:00:04.783  11:26:43.809 DEBUG: 'C# Unit Test Results Import' skipped
>>>> because there is no related file in current project
>>>> 00:00:04.783  11:26:43.809 DEBUG: 'VB.NET' skipped because there is no
>>>> related file in current project
>>>> 00:00:04.783  11:26:43.809 DEBUG: 'VB.NET Tests Coverage Report
>>>> Import' skipped because there is no related file in current project
>>>> 00:00:04.783  11:26:43.809 DEBUG: '[Deprecated] VB.NET Integration
>>>> Tests Coverage Report Import' skipped because there is no related file in
>>>> current project
>>>> 00:00:04.783  11:26:43.809 DEBUG: 'VB.NET Unit Test Results Import'
>>>> skipped because there is no related file in current project
>>>> 00:00:04.783  11:26:43.810 DEBUG: 'Java CPD Block Indexer' skipped
>>>> because there is no related file in current project
>>>> 00:00:04.783  11:26:43.810 DEBUG: Sensors : Zero Coverage Sensor

Re: where do I have to set the sonar-project.properties file to make sonar work in Jenkins?

2020-11-11 Thread David Karr
I have never seen the "-D" command-line option used with a space between
the option and the provided value, and the documentation never shows that
example.

On Wed, Nov 11, 2020 at 1:13 PM jesus fernandez <
jesusfernandez0...@gmail.com> wrote:

> and this is the log:
> ```
> *00:00:00.901* Injecting SonarQube environment variables using the
> configuration: SonarQube2 [Pipeline] {
>  [Pipeline] bat
> 
> *00:00:01.175* *00:00:01.175*
> C:\Users\anton\.jenkins\workspace\Boston>C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\sonar-scanner.bat
> -D sonar.projectKey=Test -D sonar.projectName=Test -D sonar.sources=. -D
> sonar.scm.disabled=true -D sonar.language=c++ -D sonar.sourceEncoding=UTF-8
>  *00:00:01.175* INFO: Scanner configuration file:
> C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
> *00:00:01.175* INFO: Project root configuration file: NONE
> *00:00:01.175* INFO: SonarScanner 4.4.0.2170
> *00:00:01.175* INFO: Java 1.8.0_261 Oracle Corporation (64-bit)
> *00:00:01.175* INFO: Windows 10 10.0 amd64
> *00:00:02.090* INFO: User cache:
> C:\WINDOWS\system32\config\systemprofile\.sonar\cache
> *00:00:02.090* INFO: Scanner configuration file:
> C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
> *00:00:02.090* INFO: Project root configuration file: NONE
> *00:00:02.090* INFO: Analyzing on SonarQube server 8.5.1
> *00:00:02.090* INFO: Default locale: "es_ES", source code encoding:
> "UTF-8"
> *00:00:02.343* WARN: SonarScanner will require Java 11 to run starting in
> SonarQube 8.x *00:00:02.343* INFO: Load global settings
> *00:00:02.343* INFO: Load global settings (done) | time=42ms
> *00:00:02.343* INFO: Server id: BF41A1F2-AXWnoupqHjnRwWgEnmvK
> *00:00:02.343* INFO: User cache:
> C:\WINDOWS\system32\config\systemprofile\.sonar\cache
> *00:00:02.343* INFO: Load/download plugins
> *00:00:02.343* INFO: Load plugins index
> *00:00:02.343* INFO: Load plugins index (done) | time=26ms
> *00:00:02.594* INFO: Load/download plugins (done) | time=50ms
> *00:00:02.846* INFO: Process project properties
> *00:00:02.846* INFO: Process project properties (done) | time=7ms
> *00:00:02.846* INFO: Execute project builders
> *00:00:02.846* INFO: Execute project builders (done) | time=1ms
> *00:00:02.846* INFO: Project key: Test
> *00:00:02.846* INFO: Base dir: C:\Users\anton\.jenkins\workspace\Boston
> *00:00:02.846* INFO: Working dir:
> C:\Users\anton\.jenkins\workspace\Boston\.scannerwork
> *00:00:03.097* INFO: Load project settings for component key: 'Test'
> *00:00:03.097* INFO: Load project settings for component key: 'Test'
> (done) | time=9ms
> *00:00:03.097* INFO: Load quality profiles
> *00:00:03.097* INFO: Load quality profiles (done) | time=38ms
> *00:00:03.097* INFO: Auto-configuring with CI 'Jenkins'
> *00:00:03.097* INFO: Load active rules
> *00:00:04.011* INFO: Load active rules (done) | time=981ms
> *00:00:04.263* INFO: Indexing files...
> *00:00:04.263* INFO: Project configuration:
> *00:00:04.263* INFO: 0 files indexed
> *00:00:04.263* INFO: - Run sensors on module Test
> *00:00:04.263* INFO: Load metrics repository
> *00:00:04.263* INFO: Load metrics repository (done) | time=13ms
> *00:00:05.178* INFO: Sensor CSS Rules [cssfamily]
> *00:00:05.178* INFO: No CSS, PHP, HTML or VueJS files are found in the
> project. CSS analysis is skipped. *00:00:05.178* INFO: Sensor CSS Rules
> [cssfamily] (done) | time=1ms
> *00:00:05.178* INFO: Sensor JaCoCo XML Report Importer [jacoco]
> *00:00:05.178* INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not
> defined. Using default locations:
> target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
> *00:00:05.178* INFO: No report imported, no coverage information will be
> imported by JaCoCo XML Report Importer *00:00:05.178* INFO: Sensor JaCoCo
> XML Report Importer [jacoco] (done) | time=3ms
> *00:00:05.178* INFO: Sensor C# Properties [csharp]
> *00:00:05.178* INFO: Sensor C# Properties [csharp] (done) | time=2ms
> *00:00:05.178* INFO: Sensor JavaXmlSensor [java]
> *00:00:05.178* INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
> *00:00:05.178* INFO: Sensor VB.NET Properties [vbnet]
> *00:00:05.178* INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
> *00:00:05.178* INFO: - Run sensors on project
> *00:00:05.178* INFO: Sensor Zero Coverage Sensor
> *00:00:05.178* INFO: Sensor Zero Coverage Sensor (done) | time=0ms
> *00:00:05.178* INFO: SCM Publisher is disabled
> *00:00:05.178* INFO: CPD Executor Calculating CPD for 0 files
> *00:00:05.178* INFO: CPD Executor CPD calculation finished (done) |
> time=0ms
> 

Re: where do I have to set the sonar-project.properties file to make sonar work in Jenkins?

2020-11-10 Thread David Karr
I believe that the mistake that most people make with running the sonarqube
scan from a CI build is TRYING to define a sonarqube properties file. It's
best to simply provide all of the required options on the sonar-scanner
command line, using "-D".

On Tue, Nov 10, 2020 at 3:44 AM jesus fernandez <
jesusfernandez0...@gmail.com> wrote:

> I am trying to learn the basics of sonarqube, I have set it up on my
> jenkins pipeline (which uses MSBuild to compile the project) and the set a
> step to execute SonarQube but after reading and watching a few tutorials
> and the documentation itself I think I got a bit lost as when my pipeline
> finishes executing I go to my SonarQube server and I my project says ```The
> main branch has no lines of code.```. I get the following log when running
> the sonarqube step on my jenkins:
> ```
> 00:10:43.369  Injecting SonarQube environment variables using the
> configuration: SonarQube
> [Pipeline] {
> [Pipeline] bat
> 00:10:43.653
> 00:10:43.653
> C:\Users\anton\.jenkins\workspace\Boston>C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\sonar-scanner.bat
>
> 00:10:43.653  INFO: Scanner configuration file:
> C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
> 00:10:43.653  INFO: Project root configuration file: NONE
> 00:10:43.653  INFO: SonarScanner 4.4.0.2170
> 00:10:43.653  INFO: Java 1.8.0_261 Oracle Corporation (64-bit)
> 00:10:43.653  INFO: Windows 10 10.0 amd64
> 00:10:44.230  INFO: User cache:
> C:\WINDOWS\system32\config\systemprofile\.sonar\cache
> 00:10:44.230  INFO: Scanner configuration file:
> C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
> 00:10:44.230  INFO: Project root configuration file: NONE
> 00:10:44.230  INFO: Analyzing on SonarQube server 8.5.1
> 00:10:44.230  INFO: Default locale: "es_ES", source code encoding: "UTF-8"
> 00:10:44.783  WARN: SonarScanner will require Java 11 to run starting in
> SonarQube 8.x
> 00:10:44.784  INFO: Load global settings
> 00:10:44.784  INFO: Load global settings (done) | time=40ms
> 00:10:44.784  INFO: Server id: BF41A1F2-AXWnoupqHjnRwWgEnmvK
> 00:10:44.784  INFO: User cache:
> C:\WINDOWS\system32\config\systemprofile\.sonar\cache
> 00:10:44.784  INFO: Load/download plugins
> 00:10:44.784  INFO: Load plugins index
> 00:10:44.784  INFO: Load plugins index (done) | time=26ms
> 00:10:44.784  INFO: Load/download plugins (done) | time=48ms
> 00:10:45.037  INFO: Process project properties
> 00:10:45.037  INFO: Process project properties (done) | time=6ms
> 00:10:45.037  INFO: Execute project builders
> 00:10:45.037  INFO: Execute project builders (done) | time=1ms
> 00:10:45.037  INFO: Project key: Boston
> 00:10:45.037  INFO: Base dir: C:\Users\anton\.jenkins\workspace\Boston
> 00:10:45.037  INFO: Working dir:
> C:\Users\anton\.jenkins\workspace\Boston\.scannerwork
> 00:10:45.301  INFO: Load project settings for component key: 'Boston'
> 00:10:45.301  INFO: Load project settings for component key: 'Boston'
> (done) | time=10ms
> 00:10:45.301  INFO: Load quality profiles
> 00:10:45.301  INFO: Load quality profiles (done) | time=27ms
> 00:10:45.301  INFO: Auto-configuring with CI 'Jenkins'
> 00:10:45.301  INFO: Load active rules
> 00:10:46.241  INFO: Load active rules (done) | time=787ms
> 00:10:46.241  INFO: Indexing files...
> 00:10:46.241  INFO: Project configuration:
> 00:10:46.241  INFO: 0 files indexed
> 00:10:46.241  INFO: - Run sensors on module Boston
> 00:10:46.241  INFO: Load metrics repository
> 00:10:46.241  INFO: Load metrics repository (done) | time=12ms
> 00:10:46.807  INFO: Sensor CSS Rules [cssfamily]
> 00:10:46.807  INFO: No CSS, PHP, HTML or VueJS files are found in the
> project. CSS analysis is skipped.
> 00:10:46.807  INFO: Sensor CSS Rules [cssfamily] (done) | time=1ms
> 00:10:46.807  INFO: Sensor JaCoCo XML Report Importer [jacoco]
> 00:10:46.807  INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined.
> Using default locations:
> target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
> 00:10:46.807  INFO: No report imported, no coverage information will be
> imported by JaCoCo XML Report Importer
> 00:10:46.807  INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) |
> time=1ms
> 00:10:46.807  INFO: Sensor C# Properties [csharp]
> 00:10:46.807  INFO: Sensor C# Properties [csharp] (done) | time=1ms
> 00:10:46.807  INFO: Sensor JavaXmlSensor [java]
> 00:10:46.807  INFO: Sensor JavaXmlSensor [java] (done) | time=0ms
> 00:10:46.807  INFO: Sensor VB.NET Properties [vbnet]
> 00:10:46.807  INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
> 00:10:46.807  INFO: - Run sensors on project
> 00:10:46.807  INFO: Sensor Zero Coverage Sensor

Re: How to get container logs in kubernetes if user has no admin access to execute kubectl commands

2020-10-29 Thread David Karr
In general, it would be pretty silly if anyone could get access to the 
internals of a pod if they didn't have the proper authentication.

Is your enterprise using Jenkins to build the applications that you deploy 
to kubernetes?  Are those builds using kubectl to do those deployments?  If 
you can see the command lines in the build output, you can see how 
authentication is done. If that information is visible, then the enterprise 
likely considers anyone who can see that information to be trusted to 
access those pods for diagnostic information, so you should be able to do 
the same thing.

On Thursday, October 29, 2020 at 7:50:32 AM UTC-7 Kari Atari wrote:

> Not sure if this would help, since I'm using Docker, not K8, but I bet 
> there's a similar option - when I a start a container I use a -v flag to 
> specify to copy the logs to the server it's running on.  This allows me to 
> have a persistent log that won't just go away if I remove and restart the 
> container.
>
> example:
> -v /path/to/server/log/directory:/path/from/container/logs/directory
>
>
> On Wed, Oct 28, 2020 at 11:43 PM touseef  wrote:
>
>> Can anyone provide pointer on  how do i get the logs of the containers 
>> running in kubernetes without using Kubectl because i dont have an access 
>> to the kubernetes cluster.
>> Is there any loging mechanism by which i can get the logs or stdout in 
>> the container to jenkins ? Help would be greatly appreciated.
>>
>> -- 
>> 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/3b38d046-c55e-4e55-b9c3-7bc1d333a821n%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/46f79f1d-4607-4556-9414-1d70ad02f3c4n%40googlegroups.com.


Re: Where is source for the "withSonarQubeEnv" and "waitForQualityGate" pipeline steps?

2020-08-12 Thread David Karr
Thanks. That's not giving me an obvious answer to my problem. I guess I'll 
have to post more details in a separate question.

On Wednesday, August 12, 2020 at 5:13:50 PM UTC-7, Richard Bywater wrote:
>
>
> https://github.com/jenkinsci/sonarqube-plugin/blob/master/src/main/java/org/sonarsource/scanner/jenkins/pipeline/WaitForQualityGateStep.java
>  is 
> probably what you are looking for.
>
> Richard.
>
> On Thu, 13 Aug 2020 at 11:27, David Karr  > wrote:
>
>> I'm trying to troubleshoot a problem with our integration between Jenkins 
>> and our enterprise SonarQube instance. I need to see the source code for 
>> the "waitForQualityGate()" pipeline step. Is that available somewhere?
>>
>> We're using a SonarQube server definition that uses "http:", but the 
>> "waitForQualityGate()" step appears to be querying tasks from sonarqube 
>> using the "https:" url.  I need to understand why it is doing that.
>>
>> -- 
>> 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/8b6301de-7d0e-480a-ba35-c1b09f82e130o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/8b6301de-7d0e-480a-ba35-c1b09f82e130o%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/5fa593d9-5a4c-4edb-85a8-081d6950f3efo%40googlegroups.com.


Where is source for the "withSonarQubeEnv" and "waitForQualityGate" pipeline steps?

2020-08-12 Thread David Karr
I'm trying to troubleshoot a problem with our integration between Jenkins 
and our enterprise SonarQube instance. I need to see the source code for 
the "waitForQualityGate()" pipeline step. Is that available somewhere?

We're using a SonarQube server definition that uses "http:", but the 
"waitForQualityGate()" step appears to be querying tasks from sonarqube 
using the "https:" url.  I need to understand why it is doing that.

-- 
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/8b6301de-7d0e-480a-ba35-c1b09f82e130o%40googlegroups.com.


Calling writeFile for every entry of a map requires somewhat ugly code

2020-07-18 Thread David Karr
I'm posting this mostly so people can find it.  Perhaps it's already 
well-known, and perhaps I'm missing some simple thing that makes this 
easier to do, but I think not.

In my Jenkinsfile, I need to iterate over a map created with Groovy, 
calling "writeFile" with the key as the file name, and the value as the 
contents.  If you haven't had to do this, you might assume this is simple. 
If you have, you either discovered what I did, or you gave up.

What I tried to write first was this:
dataMap.each {
writeFile(file: "target/generated." + key, text: value)
}

This gets serialization errors.  I then discovered that calling pipeline 
steps within closures would not work, so I changed it to a plainer 
iteration:

for(Map.Entry entry : dataMap) {
writeFile(file: "target/generated." + entry.getKey(), text: entry.
getValue())
}

This also does not work. It appears that you simply can't call a pipeline 
step with a map anywhere in scope.

What DOES work is something like the following:
def keyValueList = []
for (Map.Entry entry : dataMap) {
keyValueList.add(entry.getKey())
keyValueList.add(entry.getValue())
}
dataMap = null
for (int ctr = 0; ctr < keyValueList.size(); ctr += 2) {
writeFile(file: "target/generated." + keyValueList.get(ctr), text: 
keyValueList.get(ctr + 1))
}
keyValueList = null

Suggestions would be useful, or perhaps other people will just do the same 
thing I've done.

-- 
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/2a0ee3c2-00db-4fa0-8ae0-d3149ae664ado%40googlegroups.com.


How to get graphical staging view of a particular build instance?

2020-04-23 Thread David Karr
In the classic view, when viewing a job with the list of recent builds on 
the left, the center area shows the "Stage View" that shows how long each 
stage of the most recent builds are taking. I often want to see this data 
for builds that are not currently showing in the staging view.  I could 
manually search through the log for the lines that indicate the start of 
stages and hope that I have timestamp information near them, but it would 
be better if I could force the display of the staging view data for a 
particular build instance.  Is there any way to do that?

I'm on Jenkins ver. 2.89.4 .

-- 
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/c9650813-6067-4bd0-a02c-760c0c3baae1%40googlegroups.com.


Re: Shared library function cannot call other shared library function in separate file if called function uses "writeFile"

2020-02-08 Thread David Karr
I think you've both misunderstood what I'm saying, or I'm not being clear 
enough.

I'm not writing to write a function named "writeFile", I'm just calling 
that pipeline step from the function.  All of the function names I'm 
creating are definitely unique.  If I call the "vars" function that calls 
"writeFile", I get the seemingly generic error with no other information.  
If I instead call the inline function with contents identical to the "vars" 
function, it works fine.

On Friday, February 7, 2020 at 12:51:42 PM UTC-8, David Karr wrote:
>
> The statement I make in the subject doesn't make sense, but I don't know 
> how else to describe it.
>
> I'm working on a set of builds using scripted pipelines.  Our Jenkinsfiles 
> are very short, all of the build logic is in the shared library.  In the 
> "main" shared library function, I'm trying to call another function defined 
> in another "vars" class.  We have many of these already.  In this called 
> function, I have a call to the "writeFile" pipeline step to create a 
> temporary file used by a shell script called immediately after that.  This 
> is the only place anywhere in our builds that we call "writeFile".
>
> When I run the build, I get this very unhelpful message:
>
> Jenkins Job Failed due to Exception : 
> org.codehaus.groovy.control.ErrorCollector
>
>
> There is literally no other information provided, except for the log lines 
> that come before it.  I found that an echo statement that is called before 
> this suspect function is called is emitted in the log.  An echo statement 
> as the first line of the "call()" method of the function being called is 
> NOT emitted in the log. Somehow the act of calling the function makes it 
> die, with no explanation.
>
> So, I tried a workaround.  In the calling script file, I added a "def" at 
> the end of the file, to define an "inline function" with almost the same 
> name as the "vars" function name.  I copied the entire body of the "call()" 
> method of the vars function into that inline function.  I replaced the call 
> to the vars function with the call to the inline function.  It worked on 
> the first try.
>
> Any ideas what might cause this?
>

-- 
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/6ff2f989-046b-4d56-9d3d-d1d69487e97c%40googlegroups.com.


Shared library function cannot call other shared library function in separate file if called function uses "writeFile"

2020-02-07 Thread David Karr
The statement I make in the subject doesn't make sense, but I don't know 
how else to describe it.

I'm working on a set of builds using scripted pipelines.  Our Jenkinsfiles 
are very short, all of the build logic is in the shared library.  In the 
"main" shared library function, I'm trying to call another function defined 
in another "vars" class.  We have many of these already.  In this called 
function, I have a call to the "writeFile" pipeline step to create a 
temporary file used by a shell script called immediately after that.  This 
is the only place anywhere in our builds that we call "writeFile".

When I run the build, I get this very unhelpful message:

Jenkins Job Failed due to Exception : org.codehaus.groovy.control.ErrorCollector


There is literally no other information provided, except for the log lines 
that come before it.  I found that an echo statement that is called before 
this suspect function is called is emitted in the log.  An echo statement 
as the first line of the "call()" method of the function being called is 
NOT emitted in the log. Somehow the act of calling the function makes it 
die, with no explanation.

So, I tried a workaround.  In the calling script file, I added a "def" at 
the end of the file, to define an "inline function" with almost the same 
name as the "vars" function name.  I copied the entire body of the "call()" 
method of the vars function into that inline function.  I replaced the call 
to the vars function with the call to the inline function.  It worked on 
the first try.

Any ideas what might cause this?

-- 
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/3119e9f3-e6a8-4fa6-861a-76c9358ab300%40googlegroups.com.


Re: Jenkins job dsl- any way to dry run before affecting changes?

2019-12-30 Thread David Karr
It seems to me that the only reasonable way to "integration test" pipeline
changes before deployment is simply to deploy the changes to a job that is
not used for regular work, one that you can manually send events to, to
make sure it does what it needs to do.  This is sort of like a "canary
deployment", allowing you to do a full deployment, but without affecting
regular users and events.

On Mon, Dec 30, 2019 at 8:03 AM red 888  wrote:

> Hey, thanks for the suggestions! I know about the testing framework and
> while I may wind up using it out of necessity I think dry-run is more
> valuable than a unit test here. Let me ask you this, could I have a unit
> test that I could run locally but that that jenkins could also run first
> before executing the actual job that will accurately output what jobs are
> going to be changed and what settings are going to change for them? For
> applying configuration changes like this I think a unit test might be
> convoluted and overkill.
>
> I agree with daspilker when he out points that the dsl can contain
> arbitrary code which is not quite the same as a purely declarative language
> such as terraform but i'm still trying to treat it that way. I have a main
> entrypoint that reads a bunch of json files to find what jobs and settings
> to create- so consumers/job creators just need to add an element to a json
> config to add a new job. A dry run would allow everyone to view what is
> going to be changed before its changed. This is different then adding a new
> method or functionality to a class or adding a new feature to an
> application- this is just config which we want to confirm before applying.
>
>
> On Monday, December 30, 2019 at 8:16:58 AM UTC-5, Victor Martinez wrote:
>>
>> I've just seen your comment in the open PR regarding
>> https://issues.jenkins-ci.org/browse/JENKINS-27182
>>
>> > What I want is for my seed job to first output what it's going to
>> change and wait for user input, then if the user confirms make the changes
>> IIUC, you would like to mimic a kind of code review similar to the GitHub
>> Pull Request view process, if so, I'd say you can use the proposal from
>> Daniel Spilker (
>> https://github.com/jenkinsci/job-dsl-plugin/pull/395#issuecomment-132346716)
>> with https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts and
>> the pipeline to validate it:
>>
>> > There is currently no built-in way to do this but are there at least
>> any hacky workarounds? For example is there any way I can wrap the
>> multibranchPipelineJob('example'){} closure or extend it in some way where
>> I could have it output what changes its going to make?
>>
>> https://plugins.jenkins.io/jobConfigHistory might help you
>>
>> My two cents
>>
> --
> 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/ac15984c-9c36-4266-8f11-5c6f0d778855%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/CAA5t8Vr2HpAEz9ufSLu4UXnUNsSCk2E5F-j4-QNHGdW8QcBbLA%40mail.gmail.com.


Re: Get stage name in pipeline

2019-08-25 Thread David Karr
On Fri, Aug 23, 2019 at 3:42 AM Sureshkumar Ramar <
sureshkumar.ra...@gmail.com> wrote:

> Hi,
> i am using jenkins pipeline. i want to send the failed stage name to the
> developer. is there a way to capture the failure stage in jenkins. it
> should work in parallel stages also.
>

The basic idea is to define a global variable that holds the current stage
name.  At the end of the build, using whatever notification mechanisms you
have available, you send that stage name variable in the notification.

You define a global function called something like "mystage" that looks
something like this:

 def mystage(String stageName, Closure body) {
 env.GLOBAL_STAGE_NAME = stageName
 stage (stageName) {
 try {
 body()
 } catch (err) {
 env.GLOBAL_STAGE_NAME = stageName
 throw err
 }
 }


Then, for each stage in your pipeline, you use this syntax:

mystage("name of stage") {
...
}

>
> --
> Thanks & Regards,
> Suresh Kumar R
>
> --
> 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/CAM6nqfeQ9sPjgT-nPf%2BhWDY-nuE30%3D3O6No-10WLT3G%2B-jiPvg%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/CAA5t8VoQmXxQjRbnZKC%2BhF0x4NchMcy56jgG894BAqmE1usaOQ%40mail.gmail.com.


Difficult to softcode credential references in property scripts

2019-06-24 Thread David Karr
I'm working with someone who has defined a Jenkins job that does some 
sophisticated work to set up choice properties.  Each property has a small 
script that computes the possible values.  It attempts to get the values 
from the same git repository that the Jenkinsfile resides in.  
Unfortunately, it appears that the available context in a property script 
is pretty weak.  We can't use "withCredentials", because this isn't 
executing in the context of a build job.

Someone suggested having a separate job get these credentials and then 
write them to a file using "archiveArtifacts", and then somehow read the 
contents of that artifact in the property script.  Does that seem like it 
would be even possible?

-- 
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/714a-92bd-4465-8253-48ebd6579f24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can multibranch pipeline support user-selected branch?

2019-06-12 Thread David Karr
On Wed, Jun 12, 2019 at 12:15 PM Ivan Fernandez Calvo <
kuisathave...@gmail.com> wrote:

> I do not get your point, Multibranch pipeline creates a new job for each
> branch that match with the criteria you specify, so you have a job for
> every branch, I do not understand what do you mean with ’ I want whoever
> kicks off the job to be able to specify that only particular branches will
> build at different time’ maybe you can do do it with the ’when’ directive
> https://jenkins.io/doc/book/pipeline/syntax/#when


In the situation where we use this syntax, the job is not spawned from
within a pipeline job, it's spawned from an external trigger in BitBucket.

>
>
> --
> 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/1ae42c9f-7845-4511-8cf5-d554b66cdcb5%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vq4qETk0WDXSwXvou4GYUPk%2Bv4BcY1rikoTLtOOjXsAQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can multibranch pipeline support user-selected branch?

2019-06-11 Thread David Karr
On Tue, Jun 11, 2019 at 1:47 PM Guy Knights  wrote:

> I've been looking into multibranch pipeline and I'm wondering, can it be
> configured to support build parameters to specify which branches will be
> built?
>
> I know the branch config can be setup with a regex to specify that certain
> branches will be built, but it means that the same branches will be built
> every time. I want whoever kicks off the job to be able to specify that
> only particular branches will build at different times.
>

I'm not sure if this is what you're looking for, but a multibranch pipeline
can be specifically fired for a particular branch, with a url like this:

http://host:port
/jenkins/job//job//job/${PULL_REQUEST_TO_BRANCH}/buildWithParameters?...


> Thanks,
> Guy
>
> --
> 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/CANNH9msUkO1_Z3dF22%3D28qwToq%2BzfiNqcoe5ShHHfbVzN38G1A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VrKE9u-6WbRQGG13ijBmv3KA%3D-uMbWOHNrT9LcLe91O2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to have a scripted pipeline read POST data?

2019-06-10 Thread David Karr
I've worked on several scripted pipelines that read job parameters.  I'm 
looking at writing one that takes POST data, from the BitBucket Webhook 
plugin.  What do I have to do in a scripted pipeline to read POST data like 
this?

-- 
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/d7a17faf-38c1-4cdf-b54e-4907d2a90451%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Opinions about aggressive reuse strategy for Jenkins pipelines

2019-04-19 Thread David Karr
I'm finding that simply moving the entire jenkinsfile into a single vars 
method works well enough, but they've taken this another step further by 
moving all the separate "def" methods called from the main method into 
separate vars methods.  I wouldn't think there'd be any technical reason 
why this would be a problem, but I'm occasionally seeing weird symptoms 
with these "second-level" vars methods. I find that sometimes it gets to 
the point where it calls one of those methods, and then just fails the 
build at that point without any diagnostic at all.  My workaround for those 
issues has been to simply make an exact copy of that second-level method 
and define it as a "def" method inside the main file, and that fixes the 
problem entirely. I didn't even change any of the code of the method, I 
just copied it into the main file, and that fixed the problem.

On Tuesday, April 9, 2019 at 9:37:32 AM UTC-7, David Karr wrote:
>
> I work for a very large organization, on a project with many teams, 
> working on many microservices, all of which were generated from a 
> home-grown application template system.  Most of the Java-based 
> microservices have a very similar build process. In fact, most of the 
> projects have an identical Jenkinsfile, with some small parameter value 
> differences (which are set in a different system, not in the Jenkinsfile).
>
> Over time, we've evolved the template and common features, including 
> modularizing and cleaning up the Jenkinsfile.  A small shared library was 
> developed, to hold some of the core function definitions, even though the 
> basic structure of the build was still "in-line" in the Jenkinsfile.
>
> The latest version of this template has taken reuse just about as far as 
> it can go.  The entire Jenkinsfile for most projects will be a small 
> properties block to override some defaults (that are not set in the other 
> system), along with a single method call, including the shared library 
> reference.  The shared library has now expanded to specify the entire build 
> process, from that one method call.
>
> There are a handful of services in the collection that will still have 
> some custom changes (all in my domain), so I will reference a branch of the 
> shared library in those Jenkinsfiles.  If my custom changes are eventually 
> accepted as standard (many of them have been), then they will be merged to 
> the master branch and I can change our Jenkinsfiles to use the master 
> branch.
>
> I'm describing all of this for background.  What I'm asking the community 
> is, is this a reasonable strategy?  I can't help the feeling that this is 
> taking reusability a bit too far. I can't give any technical arguments 
> against it, so I'm just looking for some perspective.
>

-- 
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/fdcf2b2e-7c28-4183-93d5-0960c865ae0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Opinions about aggressive reuse strategy for Jenkins pipelines

2019-04-09 Thread David Karr
I work for a very large organization, on a project with many teams, working 
on many microservices, all of which were generated from a home-grown 
application template system.  Most of the Java-based microservices have a 
very similar build process. In fact, most of the projects have an identical 
Jenkinsfile, with some small parameter value differences (which are set in 
a different system, not in the Jenkinsfile).

Over time, we've evolved the template and common features, including 
modularizing and cleaning up the Jenkinsfile.  A small shared library was 
developed, to hold some of the core function definitions, even though the 
basic structure of the build was still "in-line" in the Jenkinsfile.

The latest version of this template has taken reuse just about as far as it 
can go.  The entire Jenkinsfile for most projects will be a small 
properties block to override some defaults (that are not set in the other 
system), along with a single method call, including the shared library 
reference.  The shared library has now expanded to specify the entire build 
process, from that one method call.

There are a handful of services in the collection that will still have some 
custom changes (all in my domain), so I will reference a branch of the 
shared library in those Jenkinsfiles.  If my custom changes are eventually 
accepted as standard (many of them have been), then they will be merged to 
the master branch and I can change our Jenkinsfiles to use the master 
branch.

I'm describing all of this for background.  What I'm asking the community 
is, is this a reasonable strategy?  I can't help the feeling that this is 
taking reusability a bit too far. I can't give any technical arguments 
against it, so I'm just looking for some perspective.

-- 
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/f959c755-7a1a-499d-bad7-f0df8da44ce6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pass the data thru variable using curl command

2019-01-22 Thread David Karr
I suggest you add "-v" to the curl command-line options and then print the
"sresponse" variable.

On Tue, Jan 22, 2019 at 11:15 AM N Panneerrselvam 
wrote:

> Def sresponse = sh scripts: status, return srdout: true
>
> On Mon, Jan 21, 2019, 09:50 David Karr 
>>
>> On Sun, Jan 20, 2019 at 8:55 PM panneerrselvam natarajan <
>> panne...@gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I am using Jenkins for API Testing in Pega Environment.  I can send and
>>> receive response thru PostMan and SOAPUI and working fine.
>>>
>>> But I want to automate using Jenkins Pipeline.
>>>
>>> Please do let me know, How do i send the data/variable thru CURL command
>>> in pipeline. I sent the data but not displayed any error message and not
>>> getting any response also
>>>
>>> I am sending the data which include special charector along with Data.
>>> Please do let me know the format.
>>>
>>
>> I suggest you show us exactly what you're doing, what the result is, and
>> what you expected. Exactly.
>>
>>
>>> Regards
>>> Panner
>>>
>>> --
>>> 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/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to jenkinsci-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VpK__XPLyskiSNB_zy-mbqBQL5DNUq2-fsDkjtLJZRTEA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VpK__XPLyskiSNB_zy-mbqBQL5DNUq2-fsDkjtLJZRTEA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CAMgnGvYLCnzMsa4Ba8C_PwAfWTOn70g3Fyc0B5ABfuR5HZq1hg%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAMgnGvYLCnzMsa4Ba8C_PwAfWTOn70g3Fyc0B5ABfuR5HZq1hg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VqATiDoj0x58MPaqgiOExaPsLJMJG%3Do76fFhDEZi_oBrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pass the data thru variable using curl command

2019-01-22 Thread David Karr
On Mon, Jan 21, 2019 at 8:18 PM Panneer  wrote:

> Hi David,
>
> My request is here below:-
>
> def status = "curl -s --max-time 30 POST 'https:url'" -H "Content-type:
> application/json" -d {"DeAppRulesList":
> [{"Applion":"02.01.02","Applime":"REFW"},{"Applion":"01.01.01","Applime":"ATP_Branch"},{"Applion":"01.06.07","Applime":"Temp_FW"}]}'
>
> No error and no response received.
>

Well, if these are ALL the lines involved in making this call, then the
answer is obvious.  All you're doing is setting a string here with a
command line to use.  You're not actually executing this command.


> Regards
> Panneer
>
>
> On Monday, January 21, 2019 at 9:50:19 AM UTC-7, David Karr wrote:
>>
>>
>> On Sun, Jan 20, 2019 at 8:55 PM panneerrselvam natarajan <
>> pann...@gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I am using Jenkins for API Testing in Pega Environment.  I can send and
>>> receive response thru PostMan and SOAPUI and working fine.
>>>
>>> But I want to automate using Jenkins Pipeline.
>>>
>>> Please do let me know, How do i send the data/variable thru CURL command
>>> in pipeline. I sent the data but not displayed any error message and not
>>> getting any response also
>>>
>>> I am sending the data which include special charector along with Data.
>>> Please do let me know the format.
>>>
>>
>> I suggest you show us exactly what you're doing, what the result is, and
>> what you expected. Exactly.
>>
>>
>>> Regards
>>> Panner
>>>
>>> --
>>> 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/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/bf8295a7-ebf9-4205-bd36-15a1c762917a%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/bf8295a7-ebf9-4205-bd36-15a1c762917a%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VrzX73NxcttBjtgi8wzJZmXdkV98CrdV8BMoVfSb_yriQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pass the data thru variable using curl command

2019-01-21 Thread David Karr
On Sun, Jan 20, 2019 at 8:55 PM panneerrselvam natarajan 
wrote:

> Hi All,
>
> I am using Jenkins for API Testing in Pega Environment.  I can send and
> receive response thru PostMan and SOAPUI and working fine.
>
> But I want to automate using Jenkins Pipeline.
>
> Please do let me know, How do i send the data/variable thru CURL command
> in pipeline. I sent the data but not displayed any error message and not
> getting any response also
>
> I am sending the data which include special charector along with Data.
> Please do let me know the format.
>

I suggest you show us exactly what you're doing, what the result is, and
what you expected. Exactly.


> Regards
> Panner
>
> --
> 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/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VpK__XPLyskiSNB_zy-mbqBQL5DNUq2-fsDkjtLJZRTEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Best way to say "never mind" in a pipeline script?

2018-12-21 Thread David Karr
First some background, although my actual question is likely pretty simple.

I have a situation where there are two different jobs that could run for 
particular projects. I have a multibranch pipeline that runs for master and 
release branches, what I might call "target" branches,being the target of a 
merge.  I also have a plain pipeline that gets spawned from BitBUcket for 
pull requests (using the "Pull Request Notification" BitBucket mechanism). 
This gets spawned for ordinary pull requests, but we also have "automerge" 
set for release branches, so when you merge a PR to a release branch, it 
automerges to master.  That also results in a pull request, but the branch 
is a release branch.  At the point the PR is merged to the release branch, 
it causes two builds to be spawned, one on the multibranch pipeline, and 
one on the plain pipeline.  I'd really like to just skip the build on the 
plain pipeline in this case.  There is no "branch filter" in the Pull 
Request Notification system, so the only time I can do something about this 
is in the pipeline script.  It's simple to detect this situation in the 
pipeline script, but what I want to determine is how to abort the script 
automatically at this point without making it look like an "error".  I 
don't know how to abort the entire pipeline script in the script itself, 
without throwing an exception.  Throwing an exception doesn't seem quite 
right.

-- 
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/95999a6a-51ed-431c-8db8-52e2bad83b19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins Pipeline code to run remote shell scripts

2018-09-17 Thread David Karr
On Mon, Sep 17, 2018 at 4:51 AM Arianrhod  wrote:

> Thanks David, I'm sure you're probably right but I've found so many
> different versions of what the 'simple' answer is that I have no real idea
> of the correct syntax for the command.  Referencing credentials that are
> already stored within the Jenkins store, for example; some say this is
> necessary, some say not, and all have different angles on how this should
> be specified.  Even the plugin page isn't really clear on the correct
> syntax, hence my question here.
>

Looking at some old pipeline code of mine, it seems pretty clear that the
"sshagent" wrapper is what you need to use. That takes a "credentials"
property that refers to the credentials object stored in Jenkins, referring
to the private key. Within that block, you can have a "sh" step calling
ssh, which doesn't have to specify any credentials.


> 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/792f625d-75a5-458e-93b7-4a4233795c92%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vqq6bfxg0_a-hudWd0UOkg3opzDC4%2BC_nfO-RSVfx7R6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins Pipeline code to run remote shell scripts

2018-09-15 Thread David Karr
On Fri, Sep 14, 2018 at 8:49 AM Arianrhod  wrote:

> Hi, I have to run two shell scripts on a remote server as part of a
> pipeline job (scripted, not via the GUI).
>
> They're both run on the same remote server, but one has to run when the
> first finishes, and they run as different users.  There is a 'jenkins' user
> account that has creds in the Jenkins creds store, that has full sudo
> access on all remote servers.
>
> Shell script one has to be run as user abc, shell script two has to be run
> as root.
>
> I have the sshAgent plugin on my Jenkins server, but cannot install any
> new plugins.
>
> Can anyone give me any idea how this can be achieved, please ... I have
> been trawling through endless Google pages for over a week trying to figure
> it out, and drawing a blank.  I'm completely new to scripting jenkinsfiles!
>

I might be missing something simple, but I would think you'd just use the
"sh" pipeline step and run "ssh" with the remote command line to run.


> 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/859367d8-2038-4ef4-9b7c-c25e9ed12d6a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VofuTAr6K3Y_SQnxWbKhUZLNJKBz%3DssHeUoTmaOOu140g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How do you evaluate the risk of allowing a particular static method call in a pipeline?

2018-09-09 Thread David Karr
When I try to call a static method in a pipeline script that doesn't have 
an existing script approval, I get an exception, which requires a script 
approval.

What exactly is the risk involved here?  How does someone evaluate the risk 
of calling a particular static method?  For instance, I needed to emit some 
json from an object, so I tried to use the JsonOutput class, which has all 
static methods.  My Jenkins admin is going through channels to determine 
whether there's a risk here, and this seems like a waste of time to me.

-- 
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/96549134-7a18-49eb-bc2f-68f10e97cec4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why do I sometimes get impossible ClassNotFoundExceptions when running two instances of the same build job at once?

2018-08-16 Thread David Karr
Our Maven build run from Jenkins occasionally gets "impossible" errors from 
the Java compiler, saying that classes that must exist are not found 
(ClassNotFoundException). Rerunning the job always resolves it.  I'm pretty 
sure this happens when more than one instance of the job is running at the 
same time.  Most of our builds are multibranch pipelines, but I'm starting 
to work on one that is a plain pipeline.  I've seen it most recently with 
the latter.  I even customized the process to ensure that each of the 
concurrent builds are using a different workspace directory (wrapping 
everything in a "ws" block). That seems to indicate that something else 
besides the workspace directory is shared between multiple instances of the 
job, that is causing these weird errors.

Any ideas what might be causing this?

I'm using Jenkins ver. 2.89.4 .

-- 
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/2475d0e5-8f21-4f36-88e8-072ff6d9735f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to make a plain pipeline (not multibranch) create a separate workspace for each instance?

2018-08-16 Thread David Karr


On Thursday, August 16, 2018 at 12:59:21 PM UTC-7, David Karr wrote:
>
> I've seen situations where Jenkins will create a separate workspace 
> directory for each instance of a job.  I've seen other situations where it 
> does not.  I think the difference is multibranch pipeline vs. plain 
> pipeline.  Is that what's going on here?
>
> I really need to figure out how to get a plain pipeline to create separate 
> workspace directories for each instance.  Is that possible to do?  I know I 
> could disable concurrent builds, but I don't want to do that in this 
> situation.  It may cause too much of a backup.
>

I am seeing situations where it is creating a separate workspace, but not 
all the time.  Sometimes it almost seems like it only does it when I don't 
need it, when I have "disable concurrent builds" turned ON. 

-- 
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/55881cad-ccfa-4361-8951-d0ed69b05686%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to make a plain pipeline (not multibranch) create a separate workspace for each instance?

2018-08-16 Thread David Karr
I've seen situations where Jenkins will create a separate workspace 
directory for each instance of a job.  I've seen other situations where it 
does not.  I think the difference is multibranch pipeline vs. plain 
pipeline.  Is that what's going on here?

I really need to figure out how to get a plain pipeline to create separate 
workspace directories for each instance.  Is that possible to do?  I know I 
could disable concurrent builds, but I don't want to do that in this 
situation.  It may cause too much of a backup.

-- 
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/392620ad-bf98-4460-8456-e88dd348a1fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Serialization error moving @NonCPS method from pipeline script to shared library

2018-03-15 Thread David Karr
Thanks for the update.  I don't even remember the specific problem I
had, but my shared library is working fine, so I must have figured it
out. :)

On Thu, Mar 15, 2018 at 1:24 PM, Martín Pianello
<martinpiane...@gmail.com> wrote:
> Hi David,
>
>
> A year later, you may have solved the issue or switched to a different
> solution altogether. Anyway, I stumbled across the same issue and coudn't
> find a definitive solution.
>
> So, after some trial & error, I wanted to post how I solved this.
>
> I followed the project structure proposed in
> https://github.com/jenkinsci/workflow-cps-plugin/blob/master/README.md
> So, the code in "vars/myClass.groovy" is just glue code calling whatever
> classes there is in "src/groovy" witch implements the real logic.
> Also, according
> https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin/issues/17
> I added the necessary @NonCPS annotations above the methods in classes
> located under src/, not in var/ (didn't work)
>
>
>
>
> El lunes, 6 de febrero de 2017, 14:23:18 (UTC-3), David Karr escribió:
>>
>> I'm trying to move duplicated methods in several pipeline scripts to a
>> shared library.  My first attempt, moving an enum type, worked fine.  My
>> next test is moving a method annotated with "@NonCPS".  I noticed in the doc
>> about writing shared libraries
>> (https://jenkins.io/doc/book/pipeline/shared-libraries/), it had the
>> following statement:
>>
>>> The Groovy source files in these directories get the same “CPS
>>> transformation” as in Scripted Pipeline.
>>
>>
>> I have no idea what that means, but I suppose it might have some relevant
>> to my problem.
>>
>> The method I'm trying to move is simply this:
>> @NonCPS
>> def computeCauseData() {
>> def result= ""
>> def causeActions =
>> currentBuild.rawBuild.getAction(hudson.model.CauseAction)
>> for (action in causeActions) {
>> println "action[${action}] displayName[${action.displayName}]"
>> for (cause in action.causes) {
>> println "cause[${cause}]
>> shortDescription[${cause.shortDescription}]"
>> result= "${cause.shortDescription}."
>> if (cause instanceof Cause.LegacyCodeCause) {
>> }
>> else if (cause instanceof TimerTrigger.TimerTriggerCause) {
>> }
>> else if (cause instanceof Cause.RemoteCause) {
>> Cause.RemoteCauseremoteCause= (Cause.RemoteCause)
>> cause
>> result= "${cause.shortDescription}:
>> Addr[${remoteCause.addr}] Note[${remoteCause.note}]."
>> }
>> else if (cause instanceof Cause.UserIdCause) {
>> }
>> else if (cause instanceof SCMTrigger.SCMTriggerCause) {
>> SCMTrigger.SCMTriggerCausescmTriggerCause=
>> (SCMTrigger.SCMTriggerCause) cause
>> println "scmTriggerCause[${scmTriggerCause}]"
>> }
>> else if (cause instanceof GitStatus.CommitHookCause) {
>> GitStatus.CommitHookCausecommitHookCause=
>> (GitStatus.CommitHookCause) cause
>> Stringsha1= commitHookCause.sha1
>> println "sha1[${sha1}]"
>> }
>> else {
>>
>> }
>> }
>> }
>>
>> return result
>> }
>>
>> This works fine in the pipeline script. When I moved it to my shared
>> library (in "vars/computeCauseData.groovy") and commented out the definition
>> in the pipeline script, and then ran my test, I got the following:
>>
>> java.io.NotSerializableException:
>> org.codehaus.groovy.control.ErrorCollector
>> at
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>> at
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>> at
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>> at
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>> at
>> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
>> at
>> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
>>
>>
>> In the past, I've avoid serialization errors by nulling 

Re: Groovy code in Pipeline and CPS trouble

2017-12-30 Thread David Karr
On Thu, Dec 28, 2017 at 6:17 AM, Ramanathan Muthaiah
 wrote:
> Hello All,
>
> I have tested the below snippet of code in myjenkinsurl/script and it works
> fine.
>
> However, same code (embedded or loaded via external Groovy code) in Pipeline
> workflow script fails, inspite of CPS annotation (with the stacktrace that's
> given after this code snippet) ?
>
> NOTE:
> First print statement in 'getjobName' function successfully matches the job
> (using regex).
>
> #!/usr/bin/env groovy
>
> import org.jenkinsci.plugins.workflow.job.*
>
> @NonCPS
> def getjobName(String job) {
> for (item in Jenkins.instance.items) {
> if (item =~ /metamon-alert-configs/ ) {
> println item.getName()
> jobname = item
> }
> }
>
> for (build in jobname.Builds()) {
> println build
> }
> }
>
>
> node('master') {
> stage('getlog') {
> def jobname = getjobName("mon-alert-configs")
> }
> }
>
>
> Reading (novice at it) the stacktrace suggests it's to do with serialization
> of variables but the annotation should take care of that, isn't it ?
>
> an exception which occurred:
> in field groovy.lang.Closure.delegate
> in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@72ae419a
> in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@401a5d46
> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@401a5d46
> Caused: java.io.NotSerializableException:
> org.jenkinsci.plugins.workflow.job.WorkflowJob
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
> at
> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
> at
> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
> at
> org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
> at
> org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
> at java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
> . . . . .
> . . . . .

No, the annotation wouldn't help with this, I believe.

The problem is, when "job steps" execute, objects are deserialized
before and after.  If Jenkins has to try to serialize something in
scope that is not serializable, you will get that exception. What is
often very frustrating is that the stacktrace won't tell you which
variable contains something that is not serializable. What it will
usually tell you is what type was not serializable. If you're lucky,
it will be obvious what variable has a value of that type. In your
case, I believe is it obvious.

The other thing that is not obvious is that "println" is a job step.

If you really need to do a println, then right before you call it, you
have to assign "null" to variables containing values of
non-serializable types.

In your "getjobName" method, it's odd that your formal parameter is
called "job", when it's really "jobName", and then you appear to
assign to "jobname", which isn't defined anywhere, but the value
actually represents a "Job", not a "jobname".

>
>
> /Ram
>
> --
> 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/68199c67-9ccf-42e2-8bf3-f38fe4708350%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VrrGDF7OJrLxeQeySmAUT4sT3mppRZY9_in1-iBbx3s1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to get named parameter in a shared library function

2017-08-25 Thread David Karr
On Fri, Aug 25, 2017 at 12:59 PM, red 888  wrote:
> I have this in my shared library in /vars/myLib.groovy:
>
> def call(Map args) {
>
> one = args.one
> two = args.two
> three = args.three
>
> somePlugin(
> someParam: one,
> otherParam: two,
> anotherParam: three
> )
>
> }
>
> Then in my jenkinsfile I call it like this:
> myLib(
> one: 'sdfsdf',
> two: 'ldskfjsdjf',
> three: 'snfeknfsi'
> )
>
> This works great, but I was wondering if there is a better way to get named
> parameters or maybe there is a feature of the DSL I could leverage for
> something like this?

You can simplify it somewhat by removing the intermediate variables:

def call(Map args) {
somePlugin(
someParam: args.one,
otherParam: args.two,
anotherParam: args.three
)
}

>
> --
> 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/3292a5e4-6ac9-4876-8da1-3dbd963bb9a3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vp5Q5-Od4HvHXUfqeqNdBmOP%3Dx3y17WJvy8Qe1DWFheXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Method names for getters/setters in pipeline shared libraries

2017-08-25 Thread David Karr
You likely need to reference "myFunc.myDerp" instead.

On Fri, Aug 25, 2017 at 10:33 AM, red 888  wrote:
> Im not sure if this is a groovy thing or a jenkins shared library DSL thing
> but I don't understand how this automatic getter setter stuff works.
>
> I have this shared lib:
> /vars/myFunc.groovy
>
> I have this in it:
> def getDerp() { return something }
> def getHerp() { return something }
>
> Now in my jenkinsfile I can reference it like this:
> echo myFunc.derp
> echo myFunc.herp
>
> But I tried naming my methods like this:
> def getMyDerp() { return something }
> def getMyHerp() { return something }
>
> Now in my jenkinsfile I tried to do this:
> echo myFunc.myderp
> echo myFunc.myherp
>
> But that didn't work.
>
> I'm just curious how this works and if its possible to do method names like
> getExtraHumps.
>
>
> --
> 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/96c6a471-a94c-4fc8-b3a8-d9ea95f26be4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vq4OtUyyvST%2BgJmMddVCfu2AH8q8%2Bq57ZRV0D2n-nQ0xQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to pass parameters to Jenkins Pipeline?

2017-07-06 Thread David Karr
On Thu, Jul 6, 2017 at 10:23 AM, Kai  wrote:
> Hi,
>
> We are trying to setup a Jenkins pipeline and have a Deploy step to deploy a
> specific version of the application.
>
> The pipeline job will be invoked programmatically by another system.
>
> Is there a way to pass in parameters programmatically to the pipeline job so
> it knows which version to deploy?

This should be a good summary of your options:
https://wiki.jenkins.io/display/JENKINS/Parameterized+Build .

>
> 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/c2c2f562-acce-475c-8a5f-eb0544118113%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VpAmUbM90g6ujikFMfg_C_SGLE4ZgHwzCXDaUySMmXeng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: notifyCommit won't fire specific jobs, need help debugging

2017-06-30 Thread David Karr
On Friday, June 30, 2017 at 5:56:40 AM UTC-7, Kevin Burnett wrote:
>
> so the job that doesn't fire has parameters. what about the job in the 
> same instance that you said works? does it have parameters? i'm believe 
> i've seen jobs with parameters not get triggered, but i'm not sure if 
> that's just how it works (job with parameters never get triggered) or if 
> there are some configurations where they can get triggered by changes in 
> source control and some configurations where they cannot.
>

The two jobs are identical, except for one small difference.  The job has 
parameters, and I set defaults in the job specification.  The single 
difference is in the "Branch Specifier".  My original job has "master", but 
the copied job is blank.

Today I stepped through the "GitStatus" code in the debugger, and I have a 
clearer picture of why it's not firing my desired job.  I understood why it 
fires the other job, because the "Branch Specifier" on that job is blank, 
but mine is set to "master".  A blank Branch Specifier matches anything.

What I discovered by stepping through the code is that even though my 
"notifyCommit" is the result of merging to the "master" branch, the 
"BranchSpec" in the resulting trigger has the name of the SOURCE branch, 
not the target branch.  That "source" branch is the name of my pull request 
branch, which definitely won't match with "master".

So, knowing what you know so far, why don't I just use the copied job that 
has "blank" for the Branch Specifier?  That's because I don't appear to be 
able to run this job manually from "Build with Parameters" in the GUI.  It 
fails because the blank in "Branch Specifier" makes it look at ALL 
branches, attempting to build all of them, and at least the first one 
fails, because that older branch was before I put the Jenkinsfile directly 
in the code repo (it used to be in a separate repo).  When I run it 
interactively, I want to build a single branch, not ALL of them.

I've summarized these same details in 
https://issues.jenkins-ci.org/browse/JENKINS-45246 .

>
>
> On Monday, June 26, 2017 at 1:51:21 PM UTC-4, David Karr wrote:
>>
>> For months now, I and the local Jenkins admins I work with, have been 
>> struggling with a problem where my main jenkins job is not firing on a 
>> "notifyCommit" firing from a BitBucket instance.  We actually were able to 
>> define another job in the same Jenkins instance, pointing to the same repo, 
>> that IS fired when the notifyCommit url is hit, but we still can't get the 
>> normal job to fire.  We also see the log entry that shows the notifyCommit 
>> call, but it just doesn't start the job.
>>
>> The job works fine when we run it manually, it just doesn't fire 
>> automatically.  It also works fine when it's spawned from the 
>> "buildWithParameters" URL, which we use to build pull request branches 
>> automatically (the same job is designed to build both master and pr 
>> branches).
>>
>> We've tried numerous variations of the value in the "Branches to build" 
>> field, but it doesn't appear to make any difference.
>>
>> We're using v2.46.2 of Jenkins and v3.3.0 of the git plugin for Jenkins.
>>
>> Assuming no one here has any bright ideas about why this is happening, I 
>> figure my next step is to connect to the Jenkins instance with a remote 
>> debugger and step through the code.  In order to do that, I have to obtain 
>> the correct code to step through, and some hints on some breakpoints to set.
>>
>> I figure I at least need the source for the correct release.  When I look 
>> on github, I see a release for "2.46.3", but not "2.46.2".  I do see that 
>> github has a "3.3.0" release for the git plugin, so I assume I'm ok there.
>>
>> Assuming I can get the 2.46.2 vs. 2.46.3 issue resolved, are there any 
>> other plugins that I need to get the source for in order to properly debug 
>> this?
>>
>

-- 
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/927c3d14-e75e-42dc-8814-f40e40e34c01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


notifyCommit won't fire specific jobs, need help debugging

2017-06-26 Thread David Karr
For months now, I and the local Jenkins admins I work with, have been 
struggling with a problem where my main jenkins job is not firing on a 
"notifyCommit" firing from a BitBucket instance.  We actually were able to 
define another job in the same Jenkins instance, pointing to the same repo, 
that IS fired when the notifyCommit url is hit, but we still can't get the 
normal job to fire.  We also see the log entry that shows the notifyCommit 
call, but it just doesn't start the job.

The job works fine when we run it manually, it just doesn't fire 
automatically.  It also works fine when it's spawned from the 
"buildWithParameters" URL, which we use to build pull request branches 
automatically (the same job is designed to build both master and pr 
branches).

We've tried numerous variations of the value in the "Branches to build" 
field, but it doesn't appear to make any difference.

We're using v2.46.2 of Jenkins and v3.3.0 of the git plugin for Jenkins.

Assuming no one here has any bright ideas about why this is happening, I 
figure my next step is to connect to the Jenkins instance with a remote 
debugger and step through the code.  In order to do that, I have to obtain 
the correct code to step through, and some hints on some breakpoints to set.

I figure I at least need the source for the correct release.  When I look 
on github, I see a release for "2.46.3", but not "2.46.2".  I do see that 
github has a "3.3.0" release for the git plugin, so I assume I'm ok there.

Assuming I can get the 2.46.2 vs. 2.46.3 issue resolved, are there any 
other plugins that I need to get the source for in order to properly debug 
this?

-- 
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/37353cbf-b2d3-4afd-8730-229f952b3e38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: repo auth problems in Jenkins v2.46 copied from working v2.19 instance

2017-06-20 Thread David Karr
On Monday, June 19, 2017 at 8:33:00 AM UTC-7, David Karr wrote:
>
> I have a working Jenkins v2.19 instance.  I have a main pipeline job that 
> references a Jenkinsfile in a BitBucket repo, accessed through a ssh url.  
> The Jenkinsfile references a global shared library, also stored in 
> BitBucket with a ssh url.
>
> I'm working with someone who's trying to upgrade me to v2.46.  He's set up 
> the v2.46 instance and copied over everything from the 2.19 instance, 
> including credentials.
>
> When I first looked at the configuration of the main job in the new 
> instance, inside the "Pipeline" "Definition" section, underneath the 
> "Repository URL" field, it says this:
> Failed to connect to repository : java.lang.IllegalStateException: Cannot 
> open session, connection is not authenticated.
>
> Despite this error, it let me run a build with this specification.  
> Initially, the build would fail at the point where it tried to obtain the 
> Jenkinsfile, saying this:
>
> java.lang.IllegalStateException: Cannot open session, connection is not 
> authenticated.
>
>
> After that point, the person I'm working with did some fiddling that I'm 
> unsure about, and now we're almost in the identical state, as it's now able 
> to obtain the Jenkinsfile, but it fails almost immediately afterwards, 
> trying to obtain the global shared library, with the above exception.
>
> When we were failing to obtain the Jenkinsfile, we thought perhaps this 
> was a "known_hosts" problem.  We looked at the file on both boxes.  Both of 
> them had an entry for the BitBucket server we were connecting to.  Now that 
> we're getting the Jenkinsfile, but failing to get the shared library, I'm 
> even more confused.
>
> Besides the main Jenkins version difference, I noted the following version 
> differences with git-related plugins:
> old:
> Git client plugin 2.1.0
> Git Parameter Plug-In 0.7.0
> Git plugin 3.0.1
> 
> new:
> Git client plugin 2.4.6
> Git Parameter Plug-In 0.8.0
> Git Pipeline for Blue Ocean 1.0.1
> Git plugin 3.3.0
>
> Any ideas of what might be going on here?
>

We've made progress with this, but at least one of the changes we made that 
fixed this does not make any sense to me.

For background, at one point, the Jenkins admin who was setting this up for 
me installed both git 2.4 and "jgit" on the box.  He thought at one time 
that the use of "jgit" should be preferred, so he put the "jgit" tool 
definition first in the list of "git" tool definitions.

So, today we were at the point where we get that "Failed to connect to 
repository" message in the configuration page.  In the "Git executable" 
field, we specify "git2.4".  When we run the build, it is able to get the 
Jenkinsfile from BitBucket, but it fails on the next step, trying to obtain 
the shared library referenced from the Jenkinsfile.

We then looked at the definition of the global shared library, and we 
noticed that it was specifying to use the "jgit" executable.  We then 
changed it to the "git2.4" executable and restarted the build.  It got past 
the referenced to the shared library, but then it later failed an explicit 
"git" pipeline step with an inscrutable error.  Note that my Jenkinsfile 
(pipeline not declarative) explicitly gets the "git2.4" tool and puts it 
into the PATH (although I'm no longer sure whether this is necessary).

We then went back to the job configuration page, and it still had the 
"Failed to connect to repository" message.

At this point, we then went back into the tool definitions and reordered 
the "git" executables, swapping the order of "jgit" and "git2.4".

We then inspected the job configuration page and now the error message we 
have been seeing was GONE.  We then reran the job, and the git pipeline 
step SUCCEEDED.

I will restate the fact that the job configuration page specifically refers 
to the "git2.4" git executable, as does the PATH setting in the Jenkinsfile.

So, it appears that on the configuration page, even though it specifically 
refers to the "git2.4" executable, it was somehow using the "jgit" 
executable when it was first in the list, which appeared to cause the 
connection failure.  Similarly, the "git" pipeline step fails if "jgit" is 
first in the list, and succeeds if "git2.4" is first in the list, even 
though I specifically obtain the path to the "git2.4" executable and put it 
first in the PATH before executing the pipeline 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/ca58b6a1-6137-490e-ae8d-5955e880825a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


repo auth problems in Jenkins v2.46 copied from working v2.19 instance

2017-06-19 Thread David Karr
I have a working Jenkins v2.19 instance.  I have a main pipeline job that 
references a Jenkinsfile in a BitBucket repo, accessed through a ssh url.  
The Jenkinsfile references a global shared library, also stored in 
BitBucket with a ssh url.

I'm working with someone who's trying to upgrade me to v2.46.  He's set up 
the v2.46 instance and copied over everything from the 2.19 instance, 
including credentials.

When I first looked at the configuration of the main job in the new 
instance, inside the "Pipeline" "Definition" section, underneath the 
"Repository URL" field, it says this:
Failed to connect to repository : java.lang.IllegalStateException: Cannot 
open session, connection is not authenticated.

Despite this error, it let me run a build with this specification.  
Initially, the build would fail at the point where it tried to obtain the 
Jenkinsfile, saying this:

java.lang.IllegalStateException: Cannot open session, connection is not 
authenticated.


After that point, the person I'm working with did some fiddling that I'm 
unsure about, and now we're almost in the identical state, as it's now able 
to obtain the Jenkinsfile, but it fails almost immediately afterwards, 
trying to obtain the global shared library, with the above exception.

When we were failing to obtain the Jenkinsfile, we thought perhaps this was 
a "known_hosts" problem.  We looked at the file on both boxes.  Both of 
them had an entry for the BitBucket server we were connecting to.  Now that 
we're getting the Jenkinsfile, but failing to get the shared library, I'm 
even more confused.

Besides the main Jenkins version difference, I noted the following version 
differences with git-related plugins:
old:
Git client plugin 2.1.0
Git Parameter Plug-In 0.7.0
Git plugin 3.0.1

new:
Git client plugin 2.4.6
Git Parameter Plug-In 0.8.0
Git Pipeline for Blue Ocean 1.0.1
Git plugin 3.3.0

Any ideas of what might be going on here?

-- 
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/19a83d5d-a7e4-4721-bcea-88f5a53d9869%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Request for simple pipeline example to do checkout, run shell script, email result

2017-04-27 Thread David Karr
On Thu, Apr 27, 2017 at 3:05 AM, David Aldrich
 wrote:
> Hi
>
>
>
> Please can anyone point me to, or provide, a simple and complete pipeline
> script example to do a checkout, run a shell script and email the result?
>
>
>
> I am using svn, but a git example would be ok.

What you should do is focus on each one of these tasks separately.
Each one of these will use pipeline steps and Groovy code.  Use the
"Pipeline Syntax" link within the "Pipeline" section of the job
definition to see examples of what pipeline steps are available to
you. On this page, you can generate example code.

Doing a git checkout requires the "git" function.  Running a shell
script uses "sh", and sending email could use the "email-ext"
function, although there may be others.

-- 
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/CAA5t8VrFJ2GA3p1hoztayT1t9tH8tagvSefj2eTG5BkqZ_1%2BVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


BitBucket Plugin for Jenkins doesn't fire release pipeline job likely because release pipeline script not in SCM, how to trick it?

2017-04-14 Thread David Karr
My enterprise uses BitBucket Server and Jenkins.  For my project, I wrote a 
pipeline script that is fully parameterized, and can properly build PR 
branches, release branches, and the master branch.  Several condition 
checks do different things depending on what the branch is.

I store the Jenkinsfile on the master branch. There has never been a need 
to branch it for any release branch.

BitBucket has a "Pull Request Notification" feature that lets me fire the 
correct URL to run the pipeline on the PR branch.

BitBucket has a "BitBucket Plugin for Jenkins" that lets me specify the 
Jenkins URL, but that's about all the control I have.  If something changes 
in the repo, it "does some magic" to make Jenkins run the jobs associated 
with that branch.  The problem is, it's just not smart enough, and the 
protocol that BitBucket and Jenkins are using to decide what job to run is 
not transparent to me.

In Jenkins, the main pipeline job can be run with different branch 
parameters, so for each of our currently pending releases, I have a 
separate pipeline job with a very short script that just fires the main 
pipeline with the correct branch parameter.  I don't store this pipeline 
script in SCM, as it's only three lines long.

When someone merges a PR to a release branch in BitBucket, I want one of 
these release pipeline jobs to run, but this doesn't work, and I'm guessing 
this is the case because the release pipeline job doesn't specify any SCM 
settings.

Is there some way I can "trick" Jenkins into associating this release 
pipeline job with the particular SCM and branch, so the protocol between 
BitBucket and Jenkins will result in the proper job being fired?

-- 
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/cb258727-c03b-4c7f-a459-2864ce7b9b85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to call a function defined within my Jenkinsfile

2017-03-21 Thread David Karr
On Tue, Mar 21, 2017 at 10:02 AM, ishan jain  wrote:
> Probably i am being silly, but seriously i am not able to call a function
> which i have defined in my Jenkinsfile from within a step. Here is a sample:
>
> def meta = "something"
>
> stage (build) {
>
>   buildProject(meta)
> }
>
> def buildProject(meta) {
> return {
>   node {
>   //whatever i need to do
>   }
>   }
> }

I might be wrong, but I don't believe you can use the "node" or
"stage" DSL anywhere but in the main body of the script.

> This simply does not do anything. I tried various combos to try n call it,
> but nothing. How exactly should i call a function ?

Calling a function is simple.  Did you try having the function just do
a "println" or "echo" to verify that it got there?  If you see that,
then move on to more complex functionality.

> def meta = "something"
>
> stage (build) {
>   node {
>   buildProject(meta)
>   }
> }
>
> def buildProject(meta) {
> return {
>
>   //whatever i need to do
>
>   }
> }
>
>
>
> def meta = "something"
>
> stage (build) {
>   step {
>   buildProject(meta)
>  }
> }
>
> def buildProject(meta) {
> return {
>   node {
>   //whatever i need to do
>   }
>   }
> }
>
>
>
> def meta = "something"
>
> stage (build) {
>
>   def output =  buildProject(meta)
> }
>
> def buildProject(meta) {
> return {
>   node {
>   //whatever i need to do
>   }
>   }
> }
>
> --
> 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/1cf8438c-7bc4-44f6-9e1d-3f42ee863de2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VoV1HK%3Du2L0bje1goh5hNHNcWicj2zK78DxwO0RD%3D2pwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: building multi module projects in jenkins

2017-03-10 Thread David Karr
On Fri, Mar 10, 2017 at 8:53 AM, paul b  wrote:
> I have several projects that are multi module projects that are like the
> following
>
> Project1
> +-module1
>   +-pom.xml
> +-module2
>   +-pom.xml
>
> Each project is configuration controlled in git as their own project
>
> Now, I have created a parent project with the following flat structure.
> This is because I would like to keep each project with its own git project.
> That seems sensible for me???

A basic rule for deciding where you should separate things into their
own git repository is whether the two things need to be built
together.  If they need to be built together, then keep them in the
same repository.  The structure you've defined is not "sensible".

> Parent
> +-pom.xml
> Project1
> +-module1
>   +-pom.xml
> +-module2
>   +-pom.xml
>
> Project2
> +-module1
>   +-pom.xml
> +-module2
>   +-pom.xml
>
> The parent pom references each project like the following
>
>   
> ../project1
> ../project2
>   
>
> This is fine as per maven documentation and all works ok locally but when I
> build this from Jenkins I run into issues.  This is because Jenkins cant
> find the pom file for each project.  Basically this is down to the flat
> directory structure!  Is there any way in Jenkins that I can get over this
> issue?

Fix the problem in your repository structure, not in Jenkins.

-- 
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/CAA5t8VoW1Xy6Bsxh1QEqqH%3DE0gePLkjM8CVe3254qT-85vy%3D6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins build says successful but no output is seen

2017-02-24 Thread David Karr
I'll say again, add braces around the body of the entire stage. Stage takes
a closure.

On Fri, Feb 24, 2017, 19:21 Sharan Basappa  wrote:

> David,
>
> I will remove everything and start with just pwd. I will update how it
> goes.
> Maybe it is not related but one thing I changed recently was the native
> shell. I changed from sh to csh
>
> On Friday, 24 February 2017 17:39:07 UTC+5:30, Daniel Beck wrote:
>
>
> > On 21.02.2017, at 19:09, Sharan Basappa  wrote:
> >
> > Snippet of Jenkins log:
> >
>
> Is that the minimal Pipeline script exhibiting the problem, i.e. is the
> git checkout necessary? What happens when you remove everything but the 'sh
> "pwd"' that doesn't work, does it work then?
>
> --
> 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/76e552ca-3b77-4931-99fc-73651164d6ad%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vpc8kYi_ec8-V5w9s7RJ9gGpFhr29Rm_hUBdx%3Da8Y9hcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins build says successful but no output is seen

2017-02-23 Thread David Karr
On Wed, Feb 22, 2017 at 9:36 AM, Sharan Basappa
 wrote:
> folks, need some guidance here ... thanks
>
> On Tuesday, 21 February 2017 23:39:43 UTC+5:30, Sharan Basappa wrote:
>>
>> My Jenkins build job indicates success but none of the scripts I am
>> executing seem to do anything. I put a simple "pwd" command to echo current
>> working directory but nothing happens. All Jenkins reports is "Running shell
>> script" and then nothing is seen.
>>
>>
>> Snippet of Jenkins log:
>>
>> First time build. Skipping changelog. [Pipeline] sh
>> [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A]
>> Running shell script [Pipeline] sh
>> [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A]
>> Running shell script [Pipeline] sh
>> [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A]
>> Running shell script [Pipeline] sh
>> [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A]
>> Running shell script [Pipeline] } [Pipeline] // node [Pipeline] End of
>> Pipeline Finished: SUCCESS
>>
>>
>> Jenkinsfile that is used to define the builds:
>>
>> node { stage 'build' sh "echo ${env.BRANCH_NAME}" git url:
>> 'git@hd1:testing', branch: "${env.BRANCH_NAME}" sh "ls -rtl" sh "pwd" sh
>> "csh ${workspace}/simple.csh" sh "csh ${workspace}/source.csh" }

I'm not an expert, but I would change your syntax to "stage ('build')
{ ... }". The parens probably aren't necessary, but the closure syntax
likely is.

-- 
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/CAA5t8VoRVBPFv52GKzNLc7mYGxr_v4ooL20_r_JWeH5ORSALXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute shell script on remote host using ssh - Jenkinsfile

2017-02-19 Thread David Karr
On Sat, Feb 18, 2017 at 9:10 AM, jequals5  wrote:
> Hello all. First time poster, long time stalker.
> I am trying to find an example of executing a shell script on a remote host
> using ssh. There is the plugin for this but I want to convert that action in
> to a Jenkinsfile.
> Any help is appreciated.

Here's a paraphrased example from one of my Jenkinsfiles:
---
withCredentials([[$class:
'UsernamePasswordMultiBinding', credentialsId: params.credentials,
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sshagent (credentials: [params.privateKey]) {
sh "ssh -o StrictHostKeyChecking=no
${USERNAME}@${params.host} \"docker stop ${params.containerName}\""
}
}


-- 
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/CAA5t8Vo2We%3DWuCrMczWshvwuDjgeMM_iO2H%2BXev6%2Ba3g_7OGDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't output clear text from secret text

2017-02-19 Thread David Karr
On Thu, Feb 16, 2017 at 7:45 AM, John Marks  wrote:

> I just wanted to test secret text, but the job always outputs "" when
> I try to echo the bound variable from a shell script job.
>
>
> 
>
>
> Shell script:
>
> set +x
> echo "My secret is $username"
>
> What I see in the console:
>
> Started by user GMAS
> [EnvInject] - Loading node environment variables.
> Building in workspace /u02/app/jenkins/.jenkins/workspace/c-test
> [c-test] $ /bin/sh -xe /u02/app/jenkins/apache-tomcat-8.0.26/temp/
> hudson5680487019107036432.sh
> + set +x
> My secret is 
> Finished: SUCCESS
>
> Probably something really obvious that I'm missing. Can someone help?
>

Did you try referencing "${username.toString()}" instead?

-- 
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/CAA5t8Voqus8RrGdd5s%2BScT_CJt3dV6C9M8_5PF%3DBiPRD2NBFbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Disable standard output from Jenkins pipeline:

2017-02-19 Thread David Karr
On Thu, Feb 16, 2017 at 8:23 AM, Geethalakshmi Ramachandran
 wrote:
> A jenkins pipeline  calls an API that returns  metrics and prints it in the 
> console output with formatting. However, Jenkins pipeline prints standard 
> output for each command like below: How to disable this or turn it off?

If you want to control how or whether stdout is emitted from a "sh"
step, instead of calling it like this:
--
sh "command line"
-

Do:

sh returnStdout: true; script: "command line"


I suppose you could set that to "false" also,but I've never done that.

-- 
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/CAA5t8VqtAd7a_u6Nac2xO%2BZhitVy3wDeaQ0eP65-0a-YdUMQFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Define parameters for a group of jobs

2017-02-13 Thread David Karr
On Monday, February 13, 2017 at 8:11:27 AM UTC-8, Richard Ginga wrote:
>
> Francesco, there are actually many ways to do this.
>
> 1. use Pipeline script or System groovy build step or post build - 
> "trigger parameterized  builds on other projects" to pass in parameter x
>
> 2. with system groovy script, you can create/update a global variable that 
> all builds will see
>
> On Sat, Feb 11, 2017 at 5:43 AM, francesco desposito <
> francesco.d...@gmail.com > wrote:
>
>> Hello,
>> I want to group the jobs referring to a single project together. 
>> Then I would like to define some parameters at group level and I want 
>> that those parameters are automatically passed to the jobs belonging to 
>> that group.
>> For example I want to create a group P1 with jobs a1, b1, c1. Then I 
>> define a parameter x for P1. I would like that x is automatically defined 
>> for the jobs a1, b1, c1.
>>
>> Is that possible?
>>
>> Thanks 
>>
>
>
I understood the OP's request, which I've often wanted myself, and I don't 
see how either of those strategies would do what he wants.  I think you 
misunderstood what he's asking.

Let's say you have ten related jobs in a "project", all of which are 
parameterized, and all of which take a "Foo" parameter, a "Bar" parameter, 
and a "Something" parameter. He wants the ability to define in a single 
place that all of these jobs should expect the "Foo", "Bar", and 
"Something" parameters, instead of creating each one manually in each of 
the ten projects, copying the default value (if any) and description from 
the first one.

-- 
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/c1f1b5f4-a24f-44f6-a93d-4562d5a56e53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


println in "call()" in "vars/xx.groovy" shows in console, but println in defed method in class in "vars/xx.groovy" is just ignored

2017-02-10 Thread David Karr
I'm seeing some odd behavior with "println" calls in shared library 
methods, and a perhaps related issue with printing a shared library object 
in a Jenkinsfile.

I've been using https://jenkins.io/doc/book/pipeline/shared-libraries/ as 
my implementation guide.

I've been working on evolving a shared library.  I started with a 
Jenkinsfile with several methods that I've been copying to a handful of 
other Jenkinsfiles, so I decided it was time to remove duplication and move 
them to a shared library.  I first created a "vars/foo.groovy" with a 
"call()" method, with the body of my original "foo" method from the 
Jenkinsfile.  This worked fine, and I note that "println" calls within the 
"call" method resulted in that string in the Jenkins job console.

However, I found that the negative part of moving those methods to "vars" 
files was that I now had to pass several global variables ("params.." and 
"env..") as parameters to those methods (actually, I don't know for certain 
that I actually had to do that, but I don't think I would want to depend on 
that working).

So, I decided to try defining a class in a "vars" file, with several 
instance variables for for those "params." and "env." variables, and "def" 
methods for each of the methods that I used to have in standalone "vars" 
files.  So far, I've tested this a little bit, and functionally this 
appears to work.  However, what's very odd is that if I have a "println" 
call within one of the "def"ed methods in the class, when it's executed 
during the job, it's like it just skips over it.  The output from that line 
just doesn't appear in the console.

I also noticed another seemingly related behavior that might be something 
completely different.  The file I had created to store the class was 
"vars/uslutils.groovy" (with "class uslutils implements Serializable" in 
the file). I also implemented a "public String toString()" method in the 
defined class, which just returns a string containing all the instance 
variables in a gstring. In my Jenkinsfile, I referenced "uslutils.varname" 
and "uslutils.methodname", and that worked fine.  However, I also had a 
println call in the Jenkinsfile itself that just printed 
"uslutils[${uslutils}]".  Right after that line, I had another println call 
for "uslutils[${uslutils.toString()}]".  The output from the latter line 
appeared in the console.  The output from the former line did not appear.

-- 
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/f8037f10-15cc-4323-bf7e-cf56e9768f02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins node selection

2017-02-07 Thread David Karr
On Tuesday, February 7, 2017 at 12:36:59 PM UTC-8, Tejinder Kaur Gill wrote:
>
> How can we specify the node on which Jenkins multibranch pipeline job will 
> run,by default it run on master nd creating space issue on master ,need to 
> configure on some slave .
>

I'm frankly not certain about multibranch vs. "plain" pipeline, but in an 
ordinary pipeline script, you can pass a "label" to the node function, so 
instead of this:
node {
   ...
}

 You can do (for instance):
node("docker") {
 ...
}

By default, this will reference a node with that name, but you really 
should add "labels" to your slave definitions, expressing the kinds of 
functionality that slave can handle.  If there's one particular slave that 
should be used for docker builds, then put that label value on it.

-- 
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/5903e94d-5a48-4fea-b812-d0197bd60ef8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with pipeline

2017-02-07 Thread David Karr
On Tuesday, February 7, 2017 at 10:15:06 AM UTC-8, Sharan Basappa wrote:
>
> Hi All,
>
> I am having some trouble executing basic shell commands (highlighted in 
> red). I cant figure out the issue. Need some help. This is what I get:
>
> Branch indexing
>
> > git rev-parse --is-inside-work-tree # timeout=10
>
> Setting origin to git@hd1:testing
>
> > git config remote.origin.url git@hd1:testing # timeout=10
>
> Fetching origin...
>
> Fetching upstream changes from origin
>
> > git --version # timeout=10
>
> > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
>
> Seen branch in repository origin/master
>
> Seen branch in repository origin/test
>
> Seen branch in repository origin/test1
>
> Seen branch in repository origin/testx
>
> Seen 4 remote branches
>
> > git rev-parse --is-inside-work-tree # timeout=10
>
> Fetching changes from the remote Git repository
>
> > git config remote.origin.url git@hd1:testing # timeout=10
>
> Fetching upstream changes from git@hd1:testing
>
> > git --version # timeout=10
>
> > git fetch --tags --progress git@hd1:testing 
> +refs/heads/*:refs/remotes/origin/*
>
> Checking out Revision eb966a50720c888113925000ad9179c79b1c187b (test1)
>
> > git config core.sparsecheckout # timeout=10
>
> > git checkout -f eb966a50720c888113925000ad9179c79b1c187b
>
> > git rev-list eb966a50720c888113925000ad9179c79b1c187b # timeout=10
>
> [Pipeline] stage (build)
>
> Using the ‘stage’ step without a block argument is deprecated
>
> Entering stage build
>
> Proceeding
>
> [Pipeline] node
>
> Running on master in 
> /var/lib/jenkins/workspace/an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA
>
> [Pipeline] {
>
> [Pipeline] sh
>
> [an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA] 
> Running shell script
>
> + pwd
>
>
> /var/lib/jenkins/workspace/an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA
>
> [Pipeline] sh
>
> [an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA] 
> Running shell script
>
> + cat simple.csh
>
> *cat: simple.csh: No such file or directory*
>

When I run into issues like this, I often will run "sh('pwd')" and 
"sh('ls')" in the script, to verify exactly where I think I am, and what 
else is in the directory. The output from those should help.
 

> [Pipeline] }
>
> [Pipeline] // node
>
> [Pipeline] End of Pipeline
>
> ERROR: script returned exit code 1
>
> Finished: FAILURE
>
>  
>

-- 
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/7b73b757-c8d5-42eb-b047-a269aa15abd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is there any way to get Jenkins to tell me about actual compile errors instead of just failing with an anonymous error?

2017-02-07 Thread David Karr
Today I've been iterating on changes in a shared library, and I find it 
very frustrating that trivial compile errors in the library source just 
result in "ErrorCollector" stacktraces, with no useful information.  For 
instance, I had some iterations that failed because I was missing an import 
statement for a class I was referencing.  I simply added the import for the 
missing class, and the error went away.  However, I had to realize what 
class I was missing the import for.  I've managed to get Eclipse to tell me 
when I have basic Groovy syntax errors, but it doesn't tell me if I'm 
missing an import for a referenced class.

-- 
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/9ebe8956-4240-4449-a9c8-c00d203035f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Serialization error moving @NonCPS method from pipeline script to shared library

2017-02-06 Thread David Karr
I'm trying to move duplicated methods in several pipeline scripts to a 
shared library.  My first attempt, moving an enum type, worked fine.  My 
next test is moving a method annotated with "@NonCPS".  I noticed in the 
doc about writing shared libraries 
(https://jenkins.io/doc/book/pipeline/shared-libraries/), it had the 
following statement:

The Groovy source files in these directories get the same “CPS 
> transformation” as in Scripted Pipeline.


I have no idea what that means, but I suppose it might have some relevant 
to my problem.

The method I'm trying to move is simply this:
@NonCPS
def computeCauseData() {
def result= ""
def causeActions = currentBuild.rawBuild.getAction(hudson.model.
CauseAction)
for (action in causeActions) {
println "action[${action}] displayName[${action.displayName}]"
for (cause in action.causes) {
println "cause[${cause}] 
shortDescription[${cause.shortDescription}]"
result= "${cause.shortDescription}."
if (cause instanceof Cause.LegacyCodeCause) {
}
else if (cause instanceof TimerTrigger.TimerTriggerCause) {
}
else if (cause instanceof Cause.RemoteCause) {
Cause.RemoteCauseremoteCause= (Cause.RemoteCause) 
cause
result= "${cause.shortDescription}: 
Addr[${remoteCause.addr}] Note[${remoteCause.note}]."
}
else if (cause instanceof Cause.UserIdCause) {
}
else if (cause instanceof SCMTrigger.SCMTriggerCause) {
SCMTrigger.SCMTriggerCausescmTriggerCause= (
SCMTrigger.SCMTriggerCause) cause
println "scmTriggerCause[${scmTriggerCause}]"
}
else if (cause instanceof GitStatus.CommitHookCause) {
GitStatus.CommitHookCausecommitHookCause= (GitStatus
.CommitHookCause) cause
Stringsha1= commitHookCause.sha1
println "sha1[${sha1}]"
}
else {

}
}
}

return result
}

This works fine in the pipeline script. When I moved it to my shared 
library (in "vars/computeCauseData.groovy") and commented out the 
definition in the pipeline script, and then ran my test, I got the 
following:

java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at 
org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)


In the past, I've avoid serialization errors by nulling out variables 
before they cross a scope. I tried modifying this method, simply nulling 
out everything but "result" right after their last use, and that made no 
difference.  Same 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4127571d-0b9a-4d70-85af-a67bf1881a7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


In a shared library, what is the "vars/foo.txt" file USED for?

2017-02-05 Thread David Karr
So I now have a handful of pipeline scripts all reusing some global 
methods, all of which I pasted into each script, so I've started to set up 
a shared library to avoid duplication.

I'm using https://jenkins.io/doc/book/pipeline/shared-libraries/ as my 
implementation guide.

My questions have to do with the following block:

The vars directory hosts scripts that define global variables accessible 
> from Pipeline. The basename of each *.groovy file should be a Groovy (~ 
> Java) identifier, conventionally camelCased. The matching *.txt, if 
> present, can contain documentation, processed through the system’s 
> configured markup formatter (so may really be HTML, Markdown, etc., though 
> the txt extension is required).


The first thing I need to define isn't what you might call a "global 
variable", but a method.  I know they are the same thing, but I think this 
could be clearer to people who are perhaps less than experts if this 
described "global variables or methods".  I'll submit that suggestion in a 
PR, but that's not quite what I'm asking about here.

I'm wondering about this "matching *.txt" file.  It says it "can contain 
documentation, ...".  The problem is, this page says nothing about how that 
documentation is used or presented. How is this file actually used?

-- 
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/e5b4d373-0cf5-40fe-ab46-76cb10bbdca3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins2 pipeline - Global methods in shared-library fails when invoked

2017-02-02 Thread David Karr
On Thursday, February 2, 2017 at 2:13:36 PM UTC-8, Daniel Beck wrote:
>
>
> > On 02.02.2017, at 17:27, David Karr <davidmic...@gmail.com > 
> wrote: 
> > 
> > Wow, and the documentation page doesn't even MENTION this fact?  I'm 
> reading it now, and there's that underscore, completely without any 
> statement like YES, THIS REALLY NEEDS TO BE HERE.  Seriously? 
>
> Could you clarify what you're referring to? Tor Christian quoted the 
> documentation which states… 
>
> > For Shared Libraries which only define Global Variables (vars/), or a 
> Jenkinsfile which only needs a Global Variable, the annotation pattern 
> @Library('my-shared-library') _ may be useful for keeping code concise. In 
> essence, instead of annotating an unnecessary import statement, the symbol 
> _ is annotated. 
>
>
>
I perhaps phrased that stronger than it should have. However, the example 
that comes before this text uses the underscore character without 
mentioning it.  It's only this note that comes a few lines later on when 
this is mentioned. When I first wrote that reply (I did try to delete it), 
I saw the example without any explanation, and didn't notice the 
explanation until later.

-- 
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/318779d6-87fc-4edb-9f9b-1ed45a37bb8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using pipeline shared library is failing with "I don't handle protocol 'git clone ssh'"

2017-02-02 Thread David Karr
On Thursday, February 2, 2017 at 9:15:57 AM UTC-8, David Karr wrote:
>
> In Jenkins 2.19.2, I now have three different pipeline jobs using a 
> variation of the same script components, including a bunch of methods that 
> I've pasted into each script.  I'm storing each script in git, but I think 
> it's now time to define a shared library so I can remove the duplicated 
> methods.
>
> So, I created a git repo with the "src", "vars", and "resources" structure 
> (initial test only has a single class in the "src" tree), and referenced 
> that repo from the shared library definition.
>
> I first noticed that something might be wrong when I entered "1.0" in the 
> "Default Version" field and it printed "Cannot validate default version" 
> below that.  When I clicked on "show details" it said something like this:
> hudson.plugins.git.GitException: Command "/opt/app/git/1.9.0-0.14/bin/git 
> fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" 
> returned status code 128:
> stdout: 
> stderr: fatal: I don't handle protocol 'git clone ssh'
>
> at 
> org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
>
>
> Even with this, I went ahead and tried adding the reference to the library 
> in one of my pipeline scripts, only to reference the single class I put in 
> the library (a simple enum definition).  In the build output, the first 
> reference to the repo containing the shared library looks like this:
>
> Setting origin to git clone ssh://git@.../usl_jenkins_library.git
>  > /opt/app/git/1.9.0-0.14/bin/git config remote.origin.url git clone 
> ssh://git@.../usl_jenkins_library.git # timeout=10
> Fetching origin...
> Fetching upstream changes from origin
>  > /opt/app/git/1.9.0-0.14/bin/git --version # timeout=10
> using GIT_ASKPASS to set credentials 
>  > /opt/app/git/1.9.0-0.14/bin/git fetch --tags --progress origin 
> +refs/heads/*:refs/remotes/origin/*
> hudson.plugins.git.GitException: Command "/opt/app/git/1.9.0-0.14/bin/git 
> fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" returned 
> status code 128:
> stdout: 
> stderr: fatal: I don't handle protocol 'git clone ssh'
>
> at 
> org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
> at 
> org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489)
>
>
> If it matters, I modified my pipeline script to look like this:
> @Library("usl-pipeline-library")
> import com.att.usl.jenkins.BUILD_STATUS
>
> import groovy.xml.*
> import java.nio.file.*
> import hudson.model.*
> import hudson.triggers.*
> import hudson.plugins.git.GitStatus
>
>
> What might I be doing wrong here?
>

Hmm, well, this is was a head-slap error.  I didn't pay enough attention to 
what I pasted into the "repository" field.  I copied the entire "git clone" 
instruction instead of just the repository url.  Moving forward now. 

-- 
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/adae71ec-42d0-4b79-ae92-3b7bff880d64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using pipeline shared library is failing with "I don't handle protocol 'git clone ssh'"

2017-02-02 Thread David Karr
In Jenkins 2.19.2, I now have three different pipeline jobs using a 
variation of the same script components, including a bunch of methods that 
I've pasted into each script.  I'm storing each script in git, but I think 
it's now time to define a shared library so I can remove the duplicated 
methods.

So, I created a git repo with the "src", "vars", and "resources" structure 
(initial test only has a single class in the "src" tree), and referenced 
that repo from the shared library definition.

I first noticed that something might be wrong when I entered "1.0" in the 
"Default Version" field and it printed "Cannot validate default version" 
below that.  When I clicked on "show details" it said something like this:
hudson.plugins.git.GitException: Command "/opt/app/git/1.9.0-0.14/bin/git 
fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" 
returned status code 128:
stdout: 
stderr: fatal: I don't handle protocol 'git clone ssh'

at 
org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)


Even with this, I went ahead and tried adding the reference to the library 
in one of my pipeline scripts, only to reference the single class I put in 
the library (a simple enum definition).  In the build output, the first 
reference to the repo containing the shared library looks like this:

Setting origin to git clone ssh://git@.../usl_jenkins_library.git
 > /opt/app/git/1.9.0-0.14/bin/git config remote.origin.url git clone 
 > ssh://git@.../usl_jenkins_library.git # timeout=10
Fetching origin...
Fetching upstream changes from origin
 > /opt/app/git/1.9.0-0.14/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > /opt/app/git/1.9.0-0.14/bin/git fetch --tags --progress origin 
 > +refs/heads/*:refs/remotes/origin/*
hudson.plugins.git.GitException: Command "/opt/app/git/1.9.0-0.14/bin/git fetch 
--tags --progress origin +refs/heads/*:refs/remotes/origin/*" returned status 
code 128:
stdout: 
stderr: fatal: I don't handle protocol 'git clone ssh'

at 
org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
at 
org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489)


If it matters, I modified my pipeline script to look like this:
@Library("usl-pipeline-library")
import com.att.usl.jenkins.BUILD_STATUS

import groovy.xml.*
import java.nio.file.*
import hudson.model.*
import hudson.triggers.*
import hudson.plugins.git.GitStatus


What might I be doing wrong here?

-- 
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/b316a2ba-e8a2-4503-9740-e4a237187773%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins2 pipeline - Global methods in shared-library fails when invoked

2017-02-02 Thread David Karr
On Thursday, February 2, 2017 at 3:30:05 AM UTC-8, R Tyler Croy wrote:
>
> (replies inline) 
>
> On Thu, 02 Feb 2017, Tor Christian Solev?gseide wrote: 
>
> > I was finally able to solve this myself. The problem was how I 
> referenced 
> > the shared library. Apparently, I need to add the underscore character 
> to 
> > the end if my @Library annotation like this: 
> > @Library('customized-portal-lib') _ 
> > 
> > Also, I must make sure to not import my global *acme *variable. 
> > 
> > This is documented 
> > in https://jenkins.io/doc/book/pipeline/shared-libraries/ for those who 
> > take their time to fine read it (which I didn't at first): 
>
>
> FWIW, the underscore character is kind of a cute little hack. @Library is 
> an 
> annotation so it must annotate *something*, annotating the underscore is 
> kind 
> of like annotating a throwaway unused character. Technically you're able 
> to 
> annotate other statements, as the section in the handbook describes 
>

Wow, and the documentation page doesn't even MENTION this fact?  I'm 
reading it now, and there's that underscore, completely without any 
statement like YES, THIS REALLY NEEDS TO BE HERE.  Seriously?
 

>
>
> - R. Tyler Croy 
>
> -- 
>  Code:  
>   Chatter:  
>  xmpp: rty...@jabber.org  
>
>   % gpg --keyserver keys.gnupg.net --recv-key 1426C7DC3F51E16F 
> -- 
>

-- 
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/f0014c4e-2d77-4372-bf65-817b08b02b7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pipeline: wildcard for branch name

2017-01-24 Thread David Karr
On Monday, January 23, 2017 at 9:37:01 AM UTC-8, Sharan Basappa wrote:
>
> Hi,
>
> I am trying to create pipeline script such that it only a certain branches 
> following a naming style are built.
> However, pipeline bails out when I use the wildcard.
>
> The code snippet is below:
>
> stage 'build'
>
> node {
>
> git url: 'git@hd1:testing', branch: test*
>
> sh "pwd"
>
> sh "cat simple.csh"
>
> sh "echo $PATH"
>
> sh "csh simple.csh"
>
> echo("end of pipeline")
>
> }
>
>
> I see the following output from the above script:
>
>
>
> Started by user User
>
>
> [Pipeline] stage (build)
>
>
> Using the ‘stage’ step without a block argument is deprecated
>
>
> Entering stage build
>
>
> Proceeding
>
>
> [Pipeline] node
>
>
> Running on master in /var/lib/jenkins/workspace/test_build_3
>
>
> [Pipeline] {
>
>
> [Pipeline] }
>
>
> [Pipeline] // node
>
>
> [Pipeline] End of Pipeline
>
>
> groovy.lang.MissingPropertyException: No such property: test for class: 
> WorkflowScript
>
>
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
>
>
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
>
>
> at 
> com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:33)
>
>
> at 
> com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
>
>
> at WorkflowScript.run(WorkflowScript:6)
>
>
> at ___cps.transform___(Native Method)
>
>
> at 
> com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
>
>
> at 
> com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
>
>
> at 
> com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
>
>
> at sun.reflect.GeneratedMethodAccessor725.invoke(Unknown Source)
>
>
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>
> at java.lang.reflect.Method.invoke(Method.java:606)
>
>
> at 
> com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
>
>
> at 
> com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
>
>
> at com.cloudbees.groovy.cps.Next.step(Next.java:58)
>
>
> at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
>
>
> at 
> org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163)
>
>
> at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
>
>
> at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
>
>
> at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
>
>
> at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
>
>
> at 
> org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
>
>
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>
>
> at 
> hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
>
>
> at 
> jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
>
>
> at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>
>
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>
>
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>
>
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>
>
> at java.lang.Thread.run(Thread.java:744)
>
>
> Finished: FAILURE
>
>
> However, when I modify the script as follows:
>
>
> stage 'build'
>
>
> node {
>
> git url: 'git@hd1:testing', branch: test*
>
> sh "pwd"
>
> sh "cat simple.csh"
>
> sh "echo $PATH"
>
> sh "csh simple.csh"
>
> echo("end of pipeline")
>
> }
>
>
> the code executes properly and I get the following output:
>
> Started by user User
>
> [Pipeline] stage (build)
>
> Using the ‘stage’ step without a block argument is deprecated
>
> Entering stage build
>
> Proceeding
>
> [Pipeline] node
>
> Running on master in /var/lib/jenkins/workspace/test_build_3
>
> [Pipeline] {
>
> [Pipeline] git
>
>  > git rev-parse --is-inside-work-tree # timeout=10
>
> Fetching changes from the remote Git repository
>
>  > git config remote.origin.url git@hd1:testing # timeout=10
>
> Fetching upstream changes from git@hd1:testing
>
>  > git --version # timeout=10
>
>  > git fetch --tags --progress git@hd1:testing 
> +refs/heads/*:refs/remotes/origin/*
>
>  > git rev-parse refs/remotes/origin/test^{commit} # timeout=10
>
>  > git rev-parse refs/remotes/origin/origin/test^{commit} # timeout=10
>
> Checking out Revision 264dc398372cba41c026568bd764d2656ebfc511 
> (refs/remotes/origin/test)
>
>  > 

Re: [pipline] have jenkins to override default parameter's values

2017-01-19 Thread David Karr
The number of parameters is only a problem if they have to override
most of the values. If most of the parameters can take their default
values, then it's not that annoying.

They could then define a parameterized pipeline job that calls your
pipeline, so they can customize the behavior for their own site.

On Mon, Jan 16, 2017 at 6:59 PM, Dan Tran  wrote:
> Hi
>
> I have a jenkinsfile which has a bunch of parameters with default values for
> my site,  then another team would like to re-use it on their site,but the
> number parameters are overwhelming
>
> it is possible to have user the provide another file ( stored at their
> jenkins) to override the original one?
>
> I think It is a very good use case.
>
> Having user to fork out my jenkinsfile is the sign of trouble in term of
> support
>
> Thanks
>
> -Dan
>
> --
> 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/c5dcaf13-5f83-4ba2-87ca-7846b8b6c1fa%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vo%3D_pzo8aMjK7abES1A9DUqLZmB0X%3D0s3%2B0QA7%2BxHk-Wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Docker Build & Publish using --force=true in Pipeline?

2017-01-19 Thread David Karr
The plugin just runs docker commands. If the version of docker you
have installed on the box doesn't support a "--force" parameter, it
will fail.  I have no idea what the history is of that, but it seems
likely this is the cause of your problem.

On Tue, Jan 17, 2017 at 12:58 PM,   wrote:
> All right, I was incorrect about one thing- this was NOT due to Docker Build
> & Publish, but Docker Pipeline (formerly CloudBees Docker Pipeline).
> Supposedly, this was also resolved back in 1.4; I have 1.9.1. Can anyone
> think of why I'm experiencing this issue in Pipeline?
>
> Thanks!
> Jack
>
> On Monday, January 16, 2017 at 9:56:55 PM UTC-5, jbr...@snapapp.com wrote:
>>
>> Hi all,
>>
>> I'm running into an issue when executing a job to build and publish an
>> image to a registry:
>>
>> + docker tag --force=true foo:tag foo:tag
>> unknown flag: --force
>> See 'docker tag --help'.
>>
>> The relevant bit from my Jenkinsfile:
>>
>> node {
>>   stage('deploy'){
>> git branch: 'feature/branch', credentialsId: 'foo-key', url:
>> 'g...@github.com:bar/baz.git'
>> withDockerRegistry([credentialsId: 'ecr:us-east-1:foo-key', url:
>> 'https://etcetera/']) {
>> docker.image('foo:tag').push()
>> }
>>
>> Now, I see that the --force=true issue was resolved
>> (https://issues.jenkins-ci.org/browse/JENKINS-36188), and I've confirmed
>> that my plugin is up to date. Has anyone run into this? I'm planning to open
>> an issue for this unless I'm missing something.
>>
>> Thanks!
>> Jack
>
> --
> 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/071e74d8-c5e0-4c4e-afb3-3a8e550aea6d%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vq535xVZOHD14JWDusmVPD6BmVXoYzAfZDgad_FnVDzww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins with a DB?

2017-01-10 Thread David Karr
On Tue, Jan 10, 2017 at 9:00 PM, Gauthami Thyagrajan
 wrote:
> HI Veena,
>
> Even i am trying to do the same. Have you got any solution for this?
>
> If you got can u please let me know.
>
> Thanks,
> Gauthami T
>
> On Monday, October 12, 2015 at 8:29:06 PM UTC+5:30, MV wrote:
>>
>>
 Hi Jonathan,
>>
>>
>> I am looking for ways to extract code coverage details from the jenkins
>> jobs latest build information (recent 10-15 builds) and export this data
>> into MySql database to use in various tasks. Your work resembles quite
>> similar to me. Could you please give some insight on this?
>>
>> Thank you,
>> Veena


>>>
>>> What do you mean by "all the data"? More importantly, what is the
>>> ultimate goal? I wrote a script which extracts job and build information via
>>> the Jenkins API and inserts/updates a PostgreSQL database so I could analyze
>>> it more easily. Is that similar to what you're trying to do?

This is basically what SonarQube provides.  Have you looked into that?

-- 
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/CAA5t8VrCzV-yuuUoX%2BVoB-NLw9YHA_Jf3XuWq5eid0FXzgeDCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to trigger Jenkins build with parameters from Gitlab webhook?

2017-01-09 Thread David Karr
I'm not sure if this matters, but did you define that parameter in the
pipeline job?

On Mon, Jan 9, 2017 at 3:02 AM, Mark Allison  wrote:
> I have GitLab Community Edition 8.15.2 successfully trigger pipeline
> projects in Jenkins 2.32.1 using a webhook (but without any parameters). I
> want the gitlab push to trigger a build with parameters but the parameter
> value is null when it comes through to Jenkins so the build fails.
>
> The gitlab webhook looks like:
>
> http://jenkins.server:8080/project/project-a/buildWithParameters?MYPARAM=foo
>
>
> In my pipeline project I echo the parameter value out with
>
> echo "MYPARAM: ${MYPARAM}"
>
>
> and it's not set to anything. Any ideas on where I've gone wrong?
>
> --
> 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/058c423d-150e-4f17-99ca-aa0dfc2c5d50%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VrNt_5cOJXSd%2BdFMEQ4QuKWNeLDW%2BNCBgb3PX5W9cPq4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Declarative Pipeline] params.xxx does not work for git

2017-01-04 Thread David Karr
On Tue, Jan 3, 2017 at 10:46 PM, Dan Tran  wrote:
> false alarm again, i need to double quote.  Not sure if this is intended
>
>   git url: "${params.gitUrl}", branch: "${params.branch}"

That's a Groovy restriction.  A single-quoted string is only a
"string", but a double-quoted string is a "gstring", which does
parameter interpolation.

-- 
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/CAA5t8VoVWXOKxhJyJCsh7gqC2bvoTxyZF117WAjp9-9LJBbybw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Pipeline] @NonCPS causes "sh" to hang with parallel steps

2017-01-04 Thread David Karr
In short, you can't execute "pipeline steps", and "sh" is a pipeline
step, from a @NonCPS method.

On Wed, Jan 4, 2017 at 3:40 AM, Jørgen Sølvernes Sandnes
 wrote:
> Hi!
>
> I struggled for a long time trying to figure out why my parallel steps kept
> hanging when running shell commands (sh). After trying a lot of different
> things, I found out that the @NonCPS annotation caused this behavior to
> happen. See the sample Jenkinsfile below. When I commented the @NonCPS line
> out it started working again. I don't know enough about (Non)CPS stuff to
> figure out if this is the way it's supposed to work, or if it's a bug of
> some sort. Are there any experts out there who know? :)
>
> Best regards,
> Jørgen
>
> Jenkinsfile:
>
> #!groovy
> /*
>  * Reproduction of the "hanging sh" problem
>  */
> timestamps {
> node {
>
> stage ("Running in sequence") {
> echo "Start of stage running in sequence"
>
> sh "pwd"
>
> echo "End of stage running in sequence"
>}
>
> stage ("Running in parallel") {
> echo "Start of stage running in parallel"
>
> def parallelSteps = [:]
> parallelSteps["step1"] = createParallelStep()
>
> parallel parallelSteps
>
> echo "End of stage running in parallel"
> }
> }
> }
>
> @NonCPS
> def createParallelStep() {
> echo "Creates parallel step"
> return {
> node {
> echo "Running parallel step"
>
> sh "pwd"
>
> echo "Parallel step complete"
>
> }
> }
> }
>
> --
> 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/ea0445c6-d1f3-4dea-bab3-4f997e1c147c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VqxbVhp-Z7b_i3X1bkn6dpEiriGPqaQ3%2BpFBopEWtVs-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What build variable will contain text like "commit notification ", "started by timer", or "started by user "?

2016-12-31 Thread David Karr


On Saturday, December 31, 2016 at 9:24:20 PM UTC-8, Ramanathan Muthaiah 
wrote:
>
> Am interested too in gathering such details. Pls do share details when you 
> crack this nut :-)
>

Well, I've gotten some info from my SO posting: 
http://stackoverflow.com/questions/41404627/what-jenkins-pipeline-build-variable-holds-the-commit-notification-string
 
.

>From what I see of the class hierarchies, I imagine "commit notification" 
will be a "SCMTrigger" of some sort, but I think I'll have to have my 
pipeline process that event before I can tell exactly what it will look 
like.  I've at least added some debugging to print out these values when it 
comes in.  I'll add more info when I have it.
 

>
> On Saturday, December 31, 2016 at 5:53:19 AM UTC+5:30, David Karr wrote:
>>
>> In the detail for a pipeline job, there are lines like "commit 
>> notification ",  "started by timer", or "started by user ".  
>> I'd like to 
>>
> get access to that text in the pipeline job, especially if it was the 
>> first one.  I've looked through the list of variables provided in the 
>> context of the pipeline script, but I don't see anything that would 
>> obviously contain this.  How can I get this information? 
>>
>
> /Ram 
>

-- 
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/1b57a59f-0ce5-432a-b8b5-3ea714b84eb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What build variable will contain text like "commit notification ", "started by timer", or "started by user "?

2016-12-30 Thread David Karr
In the detail for a pipeline job, there are lines like "commit notification 
",  "started by timer", or "started by user ".  I'd like to get 
access to that text in the pipeline job, especially if it was the first 
one.  I've looked through the list of variables provided in the context of 
the pipeline script, but I don't see anything that would obviously contain 
this.  How can I get this information?

-- 
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/5c65fc92-ca80-4751-bd5d-7bb8ca5ff3d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Condition in pipeline

2016-12-28 Thread David Karr
It might help to realize that a pipeline script is just Groovy code.
If you need to make sure that something is only executed when the
current time is between 1pm and 2pm, just get the current time,
convert it to hour of day, and have an "if" block comparing that value
against your constraint. You may need to drill down into the details
of how to do each of those pieces, but that's the basic idea.

On Wed, Dec 28, 2016 at 1:56 AM, Stefan Lorenz  wrote:
> Hi,
>
> i have a conditional step in a build configuration that is triggered by
> time, e.g. if time is between 1:00 and 2:00.
> How do I map that in pipeline script?
>
>
>
>
> Thanks and regards
> Stefan
>
> --
> 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/786dd1ae-d4e0-4b59-953b-4e043e7e4452%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VpAAP_kyiTgB3-kQxKz4j_LpsT60huyRvDHWOPru802BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins pipeline build failing even though all steps/stages pass

2016-12-28 Thread David Karr
I'd say we would need to see all of the console output, even though
you say it reports failure.

On Tue, Dec 27, 2016 at 11:59 PM, Raj Sahae  wrote:
> Hi all,
>
> I have a pipeline that I consider to be pretty basic. Nothing complicated in
> terms of the logic. Here is a gist
> (https://gist.github.com/rajsahae/961350d0d4ea14b6b5246767ce2ab5af)
>  where I have anonymized the jenkinsfile but other than the specific names
> being changed, this file is exactly what I am running.
>
> The jenkins job running this jenkinsfile always fails. Even though all the
> scripts and steps pass. The console output does not show any reason for the
> job to fail. It simply gets to the end and reports failure.
>
> I would greatly appreciate some guidance on this as I have been struggling
> with this particular hurdle for several days now.
>
> Thanks,
> Raj
>
> --
> 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/a83d0374-dbbf-4cf0-8b6c-e150b02ea723%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VrqzF9P6RzAqbsNY75YgeJQ3AMDZNtr%2BJWOXa%2BGjeaO%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins pipeline with github organization folder, avoiding multiple checkouts

2016-12-23 Thread David Karr
On Thu, Dec 22, 2016 at 12:39 AM, Jordan Soet  wrote:
> I'm trying to set up Jenkins with the Github Organization Folder plugin but
> I'm finding that it's checking out our entire repository twice, once in the
> @script directory and once in the actual workspace directory. This is a
> problem for us because our repository is quite large (>1GB - it contains a
> number of large libraries and assets) and so this takes a while and uses up
> a lot of extra space if we want to have it building all our different
> branches.
>
> Looking online, I found a couple other people had similar problems:
> http://stackoverflow.com/questions/39452030/jenkins-pipeline-is-it-possible-to-avoid-multiple-checkout
> - this one suggests that using the Github Organization Folder plugin should
> solve the problem, but that's what I'm using and it's not.
> https://groups.google.com/forum/#!topic/jenkinsci-users/y9cJbGX1C0k - this
> one doesn't have an answer
> https://botbot.me/freenode/jenkins/2016-08-31/?page=4 - here it's suggested
> just to use the @script folder as your workspace folder, but apparently that
> won't work if we want to have separate slaves.
>
> Anyway, particularly because of the first link where it suggests that using
> the Github Organization Folder plugin should fix this, I'm wondering if I
> just have something mis-configured? Should that plugin only be grabbing the
> Jenkinsfile?

In my opinion, the overall problem here is trying to define the build
process in the same place as what you're building.  I have always felt
that the Jenkinsfile and related scripting should be in a separate
repository from what you're building. If you simply accept this
approach, you will never have these problems again.

Note that it still makes sense to have your Maven or Gradle build
script in the same repository as what it's building. Developers need
to be able to build a codebase out of the box, but the CI environment
is different.

-- 
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/CAA5t8VosXpN-LaKyPkXDX8vF4RSO21woF78ou5i%3D9JGv7gNQkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sshagent seems to cause serialization failure

2016-12-12 Thread David Karr
Oh, and I tried running this with the "sshagent" block commented out, and 
the exception does not occur (and nothing useful gets done, of course), so 
it's definitely coming from that, even though the stacktrace doesn't give 
me any hint of where it's happening in the script.

On Monday, December 12, 2016 at 4:08:02 PM UTC-8, David Karr wrote:
>
> In a Jenkinsfile, I'm trying to scp a zip file to a remote host, and ssh 
> some commands to unpack it when it gets there.
>
> I managed to add a "SSH username with private key" credential, and I can 
> see it in the "Credentials" list.  I'm referencing that uuid in my 
> "sshagent" block.
>
> When I run the job, I see the following:
>
> JP_MechIdPrivateKey[-private-key] class[java.lang.String]
>
> [ssh-agent] Using credentials 
> [ssh-agent] Looking for ssh-agent implementation...
> [ssh-agent]   Java/JNR ssh-agent
> [ssh-agent] Skipped registering BouncyCastle, not running on a remote 
> agent
> [ssh-agent] Started.
> [Pipeline] {
>
> [Pipeline] sh
> [ssh-agent] Stopped.
> [usl-parent] Running shell script
> [Pipeline] }
> [Pipeline] // sshagent
> [Pipeline] }
> [Pipeline] // dir
> [Pipeline] sh
> ...
> java.io.NotSerializableException: sun.nio.fs.UnixPath
> at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(
> RiverMarshaller.java:860)
> at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(
> BlockMarshaller.java:65)
> ...
> Caused by: an exception which occurred:
> in field locals
> in field caller
> in field e
> in field program
> in field thread
> in field body
> in field step
> in field thread
> in field this$0
> in field returnAddress
> in field parent
> in field caller
> in field parent
> in field parent
> in field parent
> in field parent
> in field capture
> in field def
> in field closures
> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@d12af23
> Finished: FAILURE
>
> The code in question looks like this:
> println "JP_MechIdPrivateKey[${JP_MechIdPrivateKey}] 
> class[${JP_MechIdPrivateKey.class.name}]"
> sshagent (credentials: [JP_MechIdPrivateKey]) {
> sh "scp ${javadocJarPath} 
> ${JP_JavadocJarHost}:/tmp"
> sh "ssh ${JP_JavadocJarHost} \"cd 
> ${JP_JavadocRootRemotePath}; rm -rf ${versionNumber}; mkdir 
> ${versionNumber}\""
> sh "ssh ${JP_JavadocJarHost} \"cd 
> ${JP_JavadocRootRemotePath}; jar xvf /tmp/${baseFileName}\""
> }
>
> I believe I've heard that in order to avoid serialization issues, I have 
> to put things in @NonCPS methods, but I don't understand what parts of this 
> would need to go into a @NonCPS method, and what CANNOT go into a @NonCPS 
> method.
>

-- 
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/7d2a0dc5-07b5-43a5-acba-bd611fefde93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


sshagent seems to cause serialization failure

2016-12-12 Thread David Karr
In a Jenkinsfile, I'm trying to scp a zip file to a remote host, and ssh 
some commands to unpack it when it gets there.

I managed to add a "SSH username with private key" credential, and I can 
see it in the "Credentials" list.  I'm referencing that uuid in my 
"sshagent" block.

When I run the job, I see the following:

JP_MechIdPrivateKey[-private-key] class[java.lang.String]

[ssh-agent] Using credentials 
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Java/JNR ssh-agent
[ssh-agent] Skipped registering BouncyCastle, not running on a remote agent
[ssh-agent] Started.
[Pipeline] {

[Pipeline] sh
[ssh-agent] Stopped.
[usl-parent] Running shell script
[Pipeline] }
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // dir
[Pipeline] sh
...
java.io.NotSerializableException: sun.nio.fs.UnixPath
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(
RiverMarshaller.java:860)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(
BlockMarshaller.java:65)
...
Caused by: an exception which occurred:
in field locals
in field caller
in field e
in field program
in field thread
in field body
in field step
in field thread
in field this$0
in field returnAddress
in field parent
in field caller
in field parent
in field parent
in field parent
in field parent
in field capture
in field def
in field closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@d12af23
Finished: FAILURE

The code in question looks like this:
println "JP_MechIdPrivateKey[${JP_MechIdPrivateKey}] 
class[${JP_MechIdPrivateKey.class.name}]"
sshagent (credentials: [JP_MechIdPrivateKey]) {
sh "scp ${javadocJarPath} ${JP_JavadocJarHost}:/tmp"
sh "ssh ${JP_JavadocJarHost} \"cd 
${JP_JavadocRootRemotePath}; rm -rf ${versionNumber}; mkdir 
${versionNumber}\""
sh "ssh ${JP_JavadocJarHost} \"cd 
${JP_JavadocRootRemotePath}; jar xvf /tmp/${baseFileName}\""
}

I believe I've heard that in order to avoid serialization issues, I have to 
put things in @NonCPS methods, but I don't understand what parts of this 
would need to go into a @NonCPS method, and what CANNOT go into a @NonCPS 
method.

-- 
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/ea3ea892-e1ac-46fe-8381-572fa453b88b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Techniques for managing an scp call to a remote box, with a specific principal

2016-12-11 Thread David Karr


On Sunday, December 11, 2016 at 1:05:19 PM UTC-8, Rachel Moreno wrote:
>
> Hi David,
>
> I don't know if I've understood what you really need, but please, take a 
> look at:
>
>- https://wiki.jenkins-ci.org/display/JENKINS/SCP+plugin
>- https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin
>
> For example, if you have a user/password you can choose "Use password 
> authentication" to configure access to remote location and then sending 
> files.
>

Yes, I've seen those two plugins, but I don't understand how I would use 
either of these from a pipeline job.

On Friday, December 9, 2016 at 11:57:00 PM UTC+1, David Karr wrote:
>
> This mostly isn't a Jenkins question, but I would think many people here 
> would have to deal with this kind of situation.
>
> I have a Jenkins pipeline job that produces a javadoc jar (among other 
> products). I'm going to need to deploy that content into a directory tree 
> on a remote box (using some variation of "scp", I assume), where the 
> directory is owned by a particular non-root user, and this directory is a 
> mapped volume to a Docker container running an apache instance.
>
> I do have a "mechanical id" (you might call it a service account) that I 
> use for automation tasks in bitbucket and jenkins. It presently isn't able 
> to log into my javadoc box, but I have root rights on the box, so I could 
> modify that.
>
> I imagine I'll need to create an ssh key to use for this. Does that make 
> sense here?
>

-- 
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/140cfb7a-bbaf-4172-84b2-c98ae4dace58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Techniques for managing an scp call to a remote box, with a specific principal

2016-12-09 Thread David Karr
This mostly isn't a Jenkins question, but I would think many people here 
would have to deal with this kind of situation.

I have a Jenkins pipeline job that produces a javadoc jar (among other 
products). I'm going to need to deploy that content into a directory tree 
on a remote box (using some variation of "scp", I assume), where the 
directory is owned by a particular non-root user, and this directory is a 
mapped volume to a Docker container running an apache instance.

I do have a "mechanical id" (you might call it a service account) that I 
use for automation tasks in bitbucket and jenkins. It presently isn't able 
to log into my javadoc box, but I have root rights on the box, so I could 
modify that.

I imagine I'll need to create an ssh key to use for this. Does that make 
sense here?

-- 
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/adf2c964-8c94-4d23-93da-91713ae73963%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Parsing XML with Pipeline script

2016-12-01 Thread David Karr
The default security restrictions are very tight.  There are many
things you can't do that would severely restrict any reasonable
scripting approach. If you control the scripts you run, there's little
point to not removing restrictions for the methods you need to call.

On Thu, Dec 1, 2016 at 8:26 AM,   wrote:
> I was trying to parse and XML file with XmlSlurper like described here
> (http://groovy-lang.org/processing-xml.html)
>
> def text = '''
> 
> 
> Groovy
> 
> 
> '''
>
> def list = new XmlSlurper().parseText(text)
>
> println list.technology.name.text()
>
> Using a GPath expression like this list.technology.name.text() works fine
> but requires an admin to allow "method groovy.lang.GroovyObject getProperty
> java.lang.String" which the script security plugin recommends against
> ("Approving this signature may introduce a security vulnerability! You are
> advised to deny it."). Since I am not the owner of the Jenkins instance, I
> am not sure I can convince them this is OK to approve.
>
> Is there a way to write the code such that it does not depend on
> GroovyObject.getProperty being permitted? Or is there someway to configure
> Jenkins so that this can work?
>
>
>
> --
> 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/648ea072-7465-4bfb-8254-ea870e1801b3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VrEFKk8Mo-FzW%2BXvJeZr0i--tp1zTjiLt60Ziq3HppFEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Why isn't there a "Managed File Reference" parameter?

2016-11-25 Thread David Karr
I really don't like how I have to provide the Maven "settings.xml" file to 
my build job.  I know I can override the default GUID value, but the whole 
mechanism just seems odd.

What I would LIKE to see is exactly how a "Credential Parameter" works.  In 
the job configuration, I just specify the principal I want, and my script 
receives it as an opaque value that doesn't need to be hardcoded anywhere. 
I'd like to be able to provide a "File ID parameter" the same way, just 
selecting the managed file from a dropdown, so nothing needs to care about 
what the actual value is.  Scripts should never have to have GUID values 
hardcoded, or values substituted for GUID values.

I know there is a "File Parameter", but that seems to be something 
different.  I'm not even sure what that does.

-- 
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/5a10b901-ceb8-4a22-9e72-bd29c1abf99a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to generate "credentialsId" for stash notifier using principal and password

2016-11-25 Thread David Karr
Never mind.  I didn't notice the "Credentials Parameter" until now.  It 
looks like that will be all that I need.

However, now I'm wondering about another place where I had to hardcode a 
hash into my pipeline script, being a file id for a Maven settings.xml 
file. I'll pursue that separately.

On Friday, November 25, 2016 at 1:10:39 PM UTC-8, David Karr wrote:
>
> I'm using Bitbucket server and Jenkins.
>
> I've defined a pipeline job that will be spawned from bitbucket when 
> commits are pushed to a branch, either from the main webhook or a pull 
> request notification.
>
> The pipeline job has to use the stash notifier plugin to notify 
> bitbucket/stash of the results of the build.
>
> Looking at the examples of using "StashNotifier", I'm wondering whether I 
> have more options for providing the "credentialsId" value.  I'm guessing I 
> could generate this value in the snippet generator and then paste it into 
> my pipeline job, or I could define a job parameter and paste that value in 
> as the default value.
>
> I don't really like either option.  I'd really like to be able to 
> configure a credentials object in the job configuration, where I only 
> specified a principal and password, and then simply generate the 
> credentialsId in the pipeline job.  Alternatively, I could specify separate 
> principal and password job parameters, but still generate the credentialsId 
> within the pipeline code.  Are either of these possible/practical?
>

-- 
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/b4de9724-7a97-48b1-9928-dd6c8f1d84ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to generate "credentialsId" for stash notifier using principal and password

2016-11-25 Thread David Karr
I'm using Bitbucket server and Jenkins.

I've defined a pipeline job that will be spawned from bitbucket when 
commits are pushed to a branch, either from the main webhook or a pull 
request notification.

The pipeline job has to use the stash notifier plugin to notify 
bitbucket/stash of the results of the build.

Looking at the examples of using "StashNotifier", I'm wondering whether I 
have more options for providing the "credentialsId" value.  I'm guessing I 
could generate this value in the snippet generator and then paste it into 
my pipeline job, or I could define a job parameter and paste that value in 
as the default value.

I don't really like either option.  I'd really like to be able to configure 
a credentials object in the job configuration, where I only specified a 
principal and password, and then simply generate the credentialsId in the 
pipeline job.  Alternatively, I could specify separate principal and 
password job parameters, but still generate the credentialsId within the 
pipeline code.  Are either of these possible/practical?

-- 
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/787e6132-239c-4f7a-8406-07bd65ee209f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Difference between "echo" and "println" in Jenkinsfile, and clarification of "pipeline steps"

2016-11-18 Thread David Karr
I see in the "Pipeline Steps" there is "echo".  I don't see "println".  
When I execute a Jenkinsfile with a "println" statement, I see "[Pipeline] 
echo" printed before the output line, as if "println" is just a synonym for 
"echo".

If I change the statement to use "echo" instead, it appears to do exactly 
the same.

The other confusion has to do with the semantics of "Pipeline Steps".  I've 
been informed in several ways that you can't execute "Pipeline Steps" in a 
@NonCPS-annotated method.  I've also been told that all the choices in the 
"Snippet Generator" dropdown are pipeline steps. However, I just tested the 
following pipeline:
node {
stage ("testing") {
def list = ["abc", "def"]
listIterator(list)
listIterator2(list)
println "done."
}
}

@NonCPS
def listIterator(List list) {
list.each { item -> println "item[${item}]" }
}

@NonCPS
def listIterator2(List list) {
list.each { item -> echo "item[${item}]" }
}

Here's the output from running that pipeline:

[Pipeline] {
[Pipeline] stage
[Pipeline] { (testing)
[Pipeline] echo
item[abc]
[Pipeline] echo
item[def]
[Pipeline] echo
item[abc]
[Pipeline] echo
item[def]
[Pipeline] echo
done.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline


In my experience, if you execute a "pipeline step" within a 
@NonCPS-annotated method, the behavior I see is that it appears to just 
exit the pipeline at the point where it would have executed that 
statement.  As you can see, this pipeline managed to get to the last 
instruction of the pipeline (printing "done"), but the "listIterator2" 
method has @NonCPS, and it calls "echo", which is a pipeline 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/ec5d5e6b-987b-43a7-a60a-a78c58c74340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confused about unexpected path through Jenkinsfile

2016-11-17 Thread David Karr
On Thursday, November 17, 2016 at 2:13:40 PM UTC-8, David Karr wrote:
>
>
> On Thursday, November 17, 2016 at 12:39:26 PM UTC-8, Daniel Beck wrote:
>>
>>
>> > On 17.11.2016, at 17:19, David Karr <davidmic...@gmail.com> wrote: 
>> > 
>> > What I am unable to find any information on is what exactly a "pipeline 
>> step" actually means. 
>>
>> Everything you'll find in the snippet generator. 
>>
>
> Ok.  I don't think I saw that clearly stated in the other sources I found.
>
> As "echo" is one of the pipeline steps, I would guess that "println" does 
> exactly the same thing, but that doesn't appear to be a pipeline step.  Is 
> that true?
>  
> Although I now understand what the limitation is, this still doesn't help 
> my current problem.  As can be seen from my example, it is aborting on 
> something that doesn't appear to be a pipeline step (unless "println" is a 
> pipeline step).  The line before that "println" that it's not hitting is a 
> "collection.get()" expression, which I'm pretty sure is not a pipeline step.
>

I've now verified that changing the reference from "collection.get(ctr)" to 
"collection[ctr]" makes it NOT abort at that point. Let me make this clear. 
If in the previous example, in the "ctr" loop, if I access the entry with 
"alwaysNotifyEmailAddressesList.get(ctr)", that aborts the pipeline. If I 
instead access it with "alwaysNotifyEmailAddressesList[ctr]", it does NOT 
abort the loop.

Unfortunately, that only gets me past that particular point. At the end of 
the loop iteration, I've tried every variation I can think of to add the 
string to the end of the "emailAddressesList" list, but no matter what, the 
pipeline exits at that line.


>
>> > I also have a feeling that the "@NonCPS"-state doesn't apply 
>> "lexically", but "dynamically".  In other words, if I'm in a @NonCPS 
>> method, and I call a non-@NonCPS method, that method is still effectively 
>> @NonCPS. 
>>
>> Yes. (Otherwise what I wrote would be trivial to work around and wouldn't 
>> matter at all…) 
>>
>>

-- 
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/df10ac98-b91d-4d25-aa26-cfff5871511d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confused about unexpected path through Jenkinsfile

2016-11-17 Thread David Karr


On Thursday, November 17, 2016 at 12:39:26 PM UTC-8, Daniel Beck wrote:
>
>
> > On 17.11.2016, at 17:19, David Karr <davidmic...@gmail.com > 
> wrote: 
> > 
> > What I am unable to find any information on is what exactly a "pipeline 
> step" actually means. 
>
> Everything you'll find in the snippet generator. 
>

Ok.  I don't think I saw that clearly stated in the other sources I found.

As "echo" is one of the pipeline steps, I would guess that "println" does 
exactly the same thing, but that doesn't appear to be a pipeline step.  Is 
that true?
 
Although I now understand what the limitation is, this still doesn't help 
my current problem.  As can be seen from my example, it is aborting on 
something that doesn't appear to be a pipeline step (unless "println" is a 
pipeline step).  The line before that "println" that it's not hitting is a 
"collection.get()" expression, which I'm pretty sure is not a pipeline step.


> > I also have a feeling that the "@NonCPS"-state doesn't apply 
> "lexically", but "dynamically".  In other words, if I'm in a @NonCPS 
> method, and I call a non-@NonCPS method, that method is still effectively 
> @NonCPS. 
>
> Yes. (Otherwise what I wrote would be trivial to work around and wouldn't 
> matter at all…) 
>
>

-- 
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/e4d06a26-fa77-453e-b386-ec584d41f740%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confused about unexpected path through Jenkinsfile

2016-11-17 Thread David Karr
On Wednesday, November 16, 2016 at 7:45:39 PM UTC-8, Daniel Beck wrote:
>
>
> > On 16.11.2016, at 22:20, David Karr <davidmic...@gmail.com > 
> wrote: 
> > 
> > I've determined that this behavior is caused by the "@NonCPS" 
> annotation. 
>
> You can't call Pipeline steps from @NonCPS annotated methods. 
>
> Basically: 
> Outside @NonCPS -- fancy Groovy features don't work 
> Inside @NonCPS -- Pipeline steps don't work 
>
>
Yes, I've heard that.  What I am unable to find any information on is what 
exactly a "pipeline step" actually means.

I also have a feeling that the "@NonCPS"-state doesn't apply "lexically", 
but "dynamically".  In other words, if I'm in a @NonCPS method, and I call 
a non-@NonCPS method, that method is still effectively @NonCPS.  This is 
another thing that I haven't found stated anywhere.

In my test case, when I change my method to @NonCPS, it aborts on very 
innocuous statements.

For instance, this is an excerpt of my @NonCPS-annotated method:
println "JP_AlwaysNotifyTheseUsers[${JP_AlwaysNotifyTheseUsers}]"
def alwaysNotifyEmailAddressesList = JP_AlwaysNotifyTheseUsers.split
(/[,]/)
println 
"alwaysNotifyEmailAddressesList[${alwaysNotifyEmailAddressesList}]"
println 
"alwaysNotifyEmailAddressesList.size[${alwaysNotifyEmailAddressesList.size()}]"
//String[] alwaysNotifyEmailAddresses = 
alwaysNotifyEmailAddressesList.toArray(new String[0]);
//println "alwaysNotifyEmailAddresses[" + 
alwaysNotifyEmailAddresses + "]"
//println "alwaysNotifyEmailAddresses0[" + 
alwaysNotifyEmailAddresses[0] + "]"
//if (alwaysNotifyEmailAddressesList.size() > 0) {
//println 
"alwaysNotifyEmailAddressesList0[${alwaysNotifyEmailAddressesList.get(0)}]"
//}
//else {
//println "alwaysNotifyEmailAddressesList is size 0."
//}
println "About to start loop."
for (int ctr = 0; ctr < alwaysNotifyEmailAddressesList.size(); ++ 
ctr) {
println "ctr[" + ctr + "]" // last line
def emailAddress = alwaysNotifyEmailAddressesList.get(ctr)
println "emailAddress[" + emailAddress + "]"
println "emailAddress[${emailAddress}]"
emailAddressesList.add(emailAddress)
}
println "emailAddressesList[${emailAddressesList}]"


Here is the output that I see in the Jenkins console:

JP_AlwaysNotifyTheseUsers[...]
[Pipeline] echo
alwaysNotifyEmailAddressesList[[...]]
[Pipeline] echo
alwaysNotifyEmailAddressesList.size[1]
[Pipeline] echo
About to start loop.
[Pipeline] echo
ctr[0]
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline


As you can see, the line marked with "last line" is the last line that 
appears to execute.  Either the "get()" call or the next println call makes 
it abort.  How are either of those a "pipeline 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/c61ede68-26af-4130-a5b0-b5350cc2e8dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confused about unexpected path through Jenkinsfile

2016-11-16 Thread David Karr
On Wednesday, November 16, 2016 at 9:43:39 AM UTC-8, David Karr wrote:
>
> Using Jenkins 2.19.2 on Linux.
>
> I'm perplexed by the behavior of my Jenkinsfile, or at least what it's 
> reporting to me.  I had it basically working, but then I added some simple 
> additional lines to gather some additional information, and now it somehow 
> just stops executing the script at some point, without any explanation or 
> stack trace.
>
> The following is the method called from a catch block in a stage where I 
> first start to see a problem:
> @NonCPS
> def notifyFailure(String stageName) {
> println 
> "result[${currentBuild.rawBuild.getPreviousBuild()?.getResult()}]"
> println "SUCCESS[${hudson.model.Result.SUCCESS}]"
> println "was.SUCCESS[${hudson.model.Result.SUCCESS == 
> currentBuild.rawBuild.getPreviousBuild()?.getResult()}]"
> try {
> println "About to call bFNMT."
> Stringbody= buildFailureNotificationMessageText(stageName)
> println "Returned from bFNMT."
> println "body[${body}]"
> }
> catch (err) {
> err.printStackTrace()
> }
> try {
> String emailAddressesStr = getLastCommitsEmails()
> println "emailAddressesStr[${emailAddressesStr}]"
> }
> catch (err) {
> err.printStackTrace
> }
> def emailAddressesList = emailAddressesStr.split(",")
> println "emailAddressesList[${emailAddressesList}]"
> emailAddressesList.each { address -> println "address[${address}]" }
> def uidsList = emailAddressesList.collect { address -> address.split(
> "@")[0] }
> println "uidsList[${uidsList}]"
> sendQMessageToUsers(["dk068x"], body)
> emailext body:body.replaceAll('\\n', ''),
>  mimeType:'text/html',
>  subject: 'BUILD FAILURE - ' + env.JOB_NAME,
>  to: 'dk0...@att.com'
> }
>
> The following is the tail of the console output, starting at the first 
> println in this method:
> result[FAILURE]
> [Pipeline] echo
> SUCCESS[SUCCESS]
> [Pipeline] echo
> was.SUCCESS[false]
> [Pipeline] echo
> About to call bFNMT.
> [Pipeline] echo
> In bFNMT.
> [Pipeline] echo
> job[unified-service-layer-build-pipeline] stageName[DEPLOY] bu[http:...]
> [Pipeline] echo
> In gLCT.
> [Pipeline] sh
> [workspace] Running shell script
> + git log -5 --date=short '--pretty=format:%cN: %cd : %s'
> [Pipeline] }
> [Pipeline] // stage
> [Pipeline] }
> [Pipeline] // node
> [Pipeline] End of Pipeline
> [DOSSIER] Response Code: 0
> [DOSSIER] Backup file created: /home/jenkins/...
> [DOSSIER] Seconds to input data: 0
> ERROR: script returned exit code 1
> Finished: FAILURE
>
> Here are the two other relevant methods that are called in this sequence:
> @NonCPS
> def buildFailureNotificationMessageText(String stageName) {
> println "In bFNMT."
> println "job[${env.JOB_NAME}] stageName[${stageName}] 
> bu[${env.BUILD_URL}]"
> def result = "${env.JOB_NAME}  color=\"red\">FAILED (stage ${stageName}).\n" +
>  "\n" +
>  "Last commits:\n" +
>  getLastCommitsText() + "\n" +
>  "\n" +
>  env.BUILD_URL
>
> println "At end of bFNMT."
> return result
> }
>
> @NonCPS
> def getLastCommitsText() {
> println "In gLCT."
> def result= sh(returnStdout:true, script:'git log -5 --date=short 
> --pretty=format:"%cN: %cd : %s"')
> println "At end of gLCT."
> return result
> }
>
> If you look at the console output, you'll see it printed "In gLCT" and 
> then it shows the "git log" command line. Then, it just seems to skip the 
> rest of the flow and jump to the end of the stage and node.
>
> Also note that this is the "DEPLOY" stage. There was a "BUILD" stage 
> before this, that executed similar methods.  It also executed a method that 
> executed a "git log" command line, and in the console output I saw the 
> first "In ..." message, then the "Running shell script" message followed by 
> the "+ git log ..." line, and then just like in the "DEPLOY" stage, it just 
> skipped to the end of the stage.  In this case, it went onto the "DEPLOY" 
> stage, so this "skipping" behavior didn't cause a failure.
>
> I'm at a loss to understand what this is doing here.
>

I've dete

Confused about unexpected path through Jenkinsfile

2016-11-16 Thread David Karr
Using Jenkins 2.19.2 on Linux.

I'm perplexed by the behavior of my Jenkinsfile, or at least what it's 
reporting to me.  I had it basically working, but then I added some simple 
additional lines to gather some additional information, and now it somehow 
just stops executing the script at some point, without any explanation or 
stack trace.

The following is the method called from a catch block in a stage where I 
first start to see a problem:
@NonCPS
def notifyFailure(String stageName) {
println 
"result[${currentBuild.rawBuild.getPreviousBuild()?.getResult()}]"
println "SUCCESS[${hudson.model.Result.SUCCESS}]"
println "was.SUCCESS[${hudson.model.Result.SUCCESS == 
currentBuild.rawBuild.getPreviousBuild()?.getResult()}]"
try {
println "About to call bFNMT."
Stringbody= buildFailureNotificationMessageText(stageName)
println "Returned from bFNMT."
println "body[${body}]"
}
catch (err) {
err.printStackTrace()
}
try {
String emailAddressesStr = getLastCommitsEmails()
println "emailAddressesStr[${emailAddressesStr}]"
}
catch (err) {
err.printStackTrace
}
def emailAddressesList = emailAddressesStr.split(",")
println "emailAddressesList[${emailAddressesList}]"
emailAddressesList.each { address -> println "address[${address}]" }
def uidsList = emailAddressesList.collect { address -> address.split("@"
)[0] }
println "uidsList[${uidsList}]"
sendQMessageToUsers(["dk068x"], body)
emailext body:body.replaceAll('\\n', ''),
 mimeType:'text/html',
 subject: 'BUILD FAILURE - ' + env.JOB_NAME,
 to: 'dk0...@att.com'
}

The following is the tail of the console output, starting at the first 
println in this method:
result[FAILURE]
[Pipeline] echo
SUCCESS[SUCCESS]
[Pipeline] echo
was.SUCCESS[false]
[Pipeline] echo
About to call bFNMT.
[Pipeline] echo
In bFNMT.
[Pipeline] echo
job[unified-service-layer-build-pipeline] stageName[DEPLOY] bu[http:...]
[Pipeline] echo
In gLCT.
[Pipeline] sh
[workspace] Running shell script
+ git log -5 --date=short '--pretty=format:%cN: %cd : %s'
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[DOSSIER] Response Code: 0
[DOSSIER] Backup file created: /home/jenkins/...
[DOSSIER] Seconds to input data: 0
ERROR: script returned exit code 1
Finished: FAILURE

Here are the two other relevant methods that are called in this sequence:
@NonCPS
def buildFailureNotificationMessageText(String stageName) {
println "In bFNMT."
println "job[${env.JOB_NAME}] stageName[${stageName}] 
bu[${env.BUILD_URL}]"
def result = "${env.JOB_NAME} FAILED 
(stage ${stageName}).\n" +
 "\n" +
 "Last commits:\n" +
 getLastCommitsText() + "\n" +
 "\n" +
 env.BUILD_URL
   
println "At end of bFNMT."
return result
}

@NonCPS
def getLastCommitsText() {
println "In gLCT."
def result= sh(returnStdout:true, script:'git log -5 --date=short 
--pretty=format:"%cN: %cd : %s"')
println "At end of gLCT."
return result
}

If you look at the console output, you'll see it printed "In gLCT" and then 
it shows the "git log" command line. Then, it just seems to skip the rest 
of the flow and jump to the end of the stage and node.

Also note that this is the "DEPLOY" stage. There was a "BUILD" stage before 
this, that executed similar methods.  It also executed a method that 
executed a "git log" command line, and in the console output I saw the 
first "In ..." message, then the "Running shell script" message followed by 
the "+ git log ..." line, and then just like in the "DEPLOY" stage, it just 
skipped to the end of the stage.  In this case, it went onto the "DEPLOY" 
stage, so this "skipping" behavior didn't cause a failure.

I'm at a loss to understand what this is doing here.

-- 
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/8d2b23ac-e753-448c-a030-d7554eb8fa7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to emit XML in Jenkinsfile, and documentation on all Jenkinsfile restrictions?

2016-11-15 Thread David Karr
On Tuesday, November 15, 2016 at 12:32:44 PM UTC-8, Daniel Beck wrote:
>
>
> > On 15.11.2016, at 17:29, David Karr <davidmic...@gmail.com > 
> wrote: 
> > 
> > I also need better understanding of the overall restrictions in a 
> Jenkinsfile, and perhaps WHY those restrictions are there. 
>
> http://groovy-sandbox.kohsuke.org/ 
> https://github.com/jenkinsci/workflow-cps-plugin/#pipeline-groovy-plugin 
>
> Note that Pipeline is best when it handles orchestration. T's not designed 
> to be a substitute for actual build tools. 
>
>
Yup, I got that.  I have to communicate build notifications to an external 
system.  The build itself is all in Maven.

-- 
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/bf8c3813-7e72-4422-8001-a5d16afdda11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble using MarkupBuilder DSL within Pipeline DSL

2016-11-15 Thread David Karr
On Tuesday, November 15, 2016 at 9:24:48 AM UTC-8, David Karr wrote:
>
> In my Jenkinsfile, I'm trying to use MarkupBuilder to construct a simple 
> XML message. I first discovered that there are default security 
> restrictions preventing the use of this class, which I was able to override.
>
> Next, I'm seeing errors that make it seem like the "methodMissing" calls 
> for XML elements within the MarkupBuilder DSL are going to the Pipeline DSL 
> instead.  I'm able to verify my method works in groovyConsole, but when I 
> run the job in Jenkins, I get an error like this:
>
> java.lang.NoSuchMethodError: No such DSL method 'statement' found among steps 
> [VersionNumber, archive, ...
>
>
> Where my method looks like this:
> def constructMessageXML(String qid, String qpassword, String contactID, 
> String text, boolean isMeeting) {
> def writer = new StringWriter()
> MarkupBuilder mb= new MarkupBuilder(writer)
> mb.message (type:"contact.send.message", id:qid, password:qpassword, 
> contactId:contactID) {
> statement (isMeeting ? [from:qid, to:contactID, text:text, type:
> "meeting"] : [from:qid, to:contactID, text:text]) {}
> }
> return writer.toString()
> }
>
>
> The list of steps from the error message are clearly from the Pipeline 
> DSL, not the MarkupBuilder DSL.
>

I've managed to resolve this.  Changing "statement" to "delegate.statement" 
gets past this. 

-- 
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/a7772e82-ae9c-45b9-a6fb-a642ae5645df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble using MarkupBuilder DSL within Pipeline DSL

2016-11-15 Thread David Karr
On Tuesday, November 15, 2016 at 9:24:48 AM UTC-8, David Karr wrote:
>
> In my Jenkinsfile, I'm trying to use MarkupBuilder to construct a simple 
> XML message. I first discovered that there are default security 
> restrictions preventing the use of this class, which I was able to override.
>
> Next, I'm seeing errors that make it seem like the "methodMissing" calls 
> for XML elements within the MarkupBuilder DSL are going to the Pipeline DSL 
> instead.  I'm able to verify my method works in groovyConsole, but when I 
> run the job in Jenkins, I get an error like this:
>
> java.lang.NoSuchMethodError: No such DSL method 'statement' found among steps 
> [VersionNumber, archive, ...
>
>
> Where my method looks like this:
> def constructMessageXML(String qid, String qpassword, String contactID, 
> String text, boolean isMeeting) {
> def writer = new StringWriter()
> MarkupBuilder mb= new MarkupBuilder(writer)
> mb.message (type:"contact.send.message", id:qid, password:qpassword, 
> contactId:contactID) {
> statement (isMeeting ? [from:qid, to:contactID, text:text, type:
> "meeting"] : [from:qid, to:contactID, text:text]) {}
> }
> return writer.toString()
> }
>
>
> The list of steps from the error message are clearly from the Pipeline 
> DSL, not the MarkupBuilder DSL.
>

Someone I work with suggested I add @NonCPS to the method.  That didn't 
make any difference. 

-- 
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/ada41467-c874-410f-abef-edd072df3d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trouble using MarkupBuilder DSL within Pipeline DSL

2016-11-15 Thread David Karr
In my Jenkinsfile, I'm trying to use MarkupBuilder to construct a simple 
XML message. I first discovered that there are default security 
restrictions preventing the use of this class, which I was able to override.

Next, I'm seeing errors that make it seem like the "methodMissing" calls 
for XML elements within the MarkupBuilder DSL are going to the Pipeline DSL 
instead.  I'm able to verify my method works in groovyConsole, but when I 
run the job in Jenkins, I get an error like this:

java.lang.NoSuchMethodError: No such DSL method 'statement' found among steps 
[VersionNumber, archive, ...


Where my method looks like this:
def constructMessageXML(String qid, String qpassword, String contactID, 
String text, boolean isMeeting) {
def writer = new StringWriter()
MarkupBuilder mb= new MarkupBuilder(writer)
mb.message (type:"contact.send.message", id:qid, password:qpassword, 
contactId:contactID) {
statement (isMeeting ? [from:qid, to:contactID, text:text, type:
"meeting"] : [from:qid, to:contactID, text:text]) {}
}
return writer.toString()
}


The list of steps from the error message are clearly from the Pipeline DSL, 
not the MarkupBuilder DSL.

-- 
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/e3adf2f8-9615-47c6-bf96-8265b63aa094%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to emit XML in Jenkinsfile, and documentation on all Jenkinsfile restrictions?

2016-11-15 Thread David Karr
I'm stepping through implementing required features for our build in a 
Pipeline job.  I've been hitting restrictions on what I can do with Groovy 
in a Jenkinsfile.  Right now, I can't figure out how to just emit valid 
XML. When I try to use MarkupBuilder, it tells me that I can't use "new 
MarkupBuilder" or "new StringWriter".  I tried other strategies, but those 
use static methods, which are also apparently not allowed.

I need to solve this particular problem, but I also need better 
understanding of the overall restrictions in a Jenkinsfile, and perhaps WHY 
those restrictions are there.

-- 
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/5b69bec4-5960-4140-8a84-451777c3b10c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What does "Use Gradle Wrapper" do in Jenkins Gradle plugin?

2016-01-17 Thread David Karr
If I have a Gradle build that uses the Gradle Wrapper, I'm assuming that if 
I have Jenkins using the Jenkins Gradle plugin and the "Use Gradle Wrapper" 
checkbox is set for the job, then Jenkins will just execute the Gradle 
Wrapper script stored in the project. Is this correct?

What exactly are the advantages of doing this, as opposed to just having a 
dumb Jenkins job execute "./gradlew"?

-- 
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/d5601b89-d87f-49a1-9038-56d0134783e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


High level difference between workflow plugin and dsl plugin?

2015-02-12 Thread David Karr
As part of a high-level presentation on Groovy that I'm giving to my 
organization, I was looking for a short statement that explains the 
difference between the workflow plugin and the dsl plugin, and the 
relationships they have with each other.  Could someone give me a short 
statement covering that?

-- 
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/c90013d7-64b0-4f46-ad72-b209e87f56b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Weird rendering of Save and Apply buttons on at least the Global Security page

2015-01-15 Thread David Karr
On Thursday, January 15, 2015 at 12:47:45 PM UTC-8, David Karr wrote:

 Jenkins ver. 1.596 on Windows 7. 

 I don't know how much of a general issue this is, but I'm trying to 
 display the Global Security page in both Chrome and Firefox, and I'm 
 seeing really weird rendering of the page, mostly concerning the Save and 
 Apply buttons. 

 When I first viewed the page in FF, I noticed that there were two buttons 
 at the bottom of the page, but only the top part of the buttons were 
 rendering.  I couldn't even read the button labels.  I tried moving the 
 vertical scrollbar, but those buttons appear to be below that scrolling 
 region, so the scrollbar didn't have any impact on that. 

 There's a big left margin to the left of the Configure Global Security 
 page and all the fields of the form.  The horizontal scrollbar is even 
 stranger.  The scrollbar thumb appears to render under the two bottom 
 buttons, so moving the horizontal scrollbar to the right moves the form 
 fields, but it doesn't move the buttons, and the scrollbar thumb disappears 
 under that region. 

 I find if I maximize the window from the window menu, it sometimes causes 
 the buttons to render correctly, but ironically this only works if the 
 window size is somewhat smaller than the entire desktop.  If the size of 
 the window is close to the size of the desktop, maximizing the window 
 doesn't fix the buttons display.  If I then narrow the window and then 
 maximize it from the window menu, it fixes the buttons. 

 I'm seeing almost identical behavior in Firefox and Chrome. 


Looks like there are some CSS problems with this version.  We've backed off 
to 1.589, and this doesn't have the problem. 

-- 
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/6cd9555f-74b2-41c5-a5b2-9d37354b16f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.