Re: Node no longer working

2021-04-12 Thread eric....@gmail.com
OK, further proof that I'm fried this week.  I needed to put the key in for 
the jenkins user, not the  user.  The jenkins user public key is 
in the authorized_hosts file for  so that he can authenticate as 
that user.  This is fixed...

On Monday, April 12, 2021 at 10:36:46 AM UTC-6 eric@gmail.com wrote:

> So I had a node up to run as a user other than Jenkins.  It stopped 
> working and I have no idea why.  My trouble-shooting ability has just 
> reached its limit.  Anyone have any ideas for me to try?  Here are my steps 
> to set it up (the RSA Key seems to be what is failing):
>
>
>1. Go to Credentials / System (shows up under Credentials) / Global 
>credentials
>2. Click Add Credentials 
>3. Kind:  SSH Username with private key 
>4. ID:  RSAKey
>Description:  RSA Key
>Username:  
>Private Key:  Select Enter directly and paste it in from results of 
>cat ~/.ssh/id_rsa (RSA should have been created without passphrase, but if 
>you created a passphrase, enter it in the Passphrase text box)
>
>5. Go to Manage Jenkins / Manage Nodes and Clouds / New Node 
>6. Name:  Node
>Description: Run as 
># of executors: 1
>Remote root directory: /home/
>Labels: Checkout
>Usage: Only build jobs with label expressions matching this node
>Launch method: Launch agents via SSH
>Host: localhost
>Credentials:  (username RSA Key)
>Host Key Verification Strategy: Non verifying Verification Strategy
>Availability: Keep this agent online as much as possible
>
> So, when I try to start the node, I get:
>
>
>
> [04/12/21 11:34:47] [SSH] Opening SSH connection to localhost:22. 
> [04/12/21 11:34:47] [SSH] WARNING: SSH Host Keys are not being verified. 
> Man-in-the-middle attacks may be possible against this connection. ERROR: 
> Server rejected the 1 private key(s) for  
> (credentialId:RSAKey/method:publickey)
> [04/12/21 11:34:47] [SSH] Authentication failed. Authentication failed. 
> [04/12/21 11:34:47] Launch failed - cleaning up connection 
> [04/12/21 11:34:47] [SSH] Connection closed.
>
> Thanks much!
> Eric
>

-- 
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/0a42daa4-1072-4995-a698-33ea0968fbc4n%40googlegroups.com.


Re: Node no longer working

2021-04-12 Thread eric....@gmail.com
Note that I have no problem ssh'ing from the jenkins user to the  
user passwordless.  The jenkins user key is in the authorized_keys file of 
the  user.  Really kind of blown away why this all of a sudden 
stopped working.  It was working fine...

On Monday, April 12, 2021 at 10:36:46 AM UTC-6 eric@gmail.com wrote:

> So I had a node up to run as a user other than Jenkins.  It stopped 
> working and I have no idea why.  My trouble-shooting ability has just 
> reached its limit.  Anyone have any ideas for me to try?  Here are my steps 
> to set it up (the RSA Key seems to be what is failing):
>
>
>1. Go to Credentials / System (shows up under Credentials) / Global 
>credentials
>2. Click Add Credentials 
>3. Kind:  SSH Username with private key 
>4. ID:  RSAKey
>Description:  RSA Key
>Username:  
>Private Key:  Select Enter directly and paste it in from results of 
>cat ~/.ssh/id_rsa (RSA should have been created without passphrase, but if 
>you created a passphrase, enter it in the Passphrase text box)
>
>5. Go to Manage Jenkins / Manage Nodes and Clouds / New Node 
>6. Name:  Node
>Description: Run as 
># of executors: 1
>Remote root directory: /home/
>Labels: Checkout
>Usage: Only build jobs with label expressions matching this node
>Launch method: Launch agents via SSH
>Host: localhost
>Credentials:  (username RSA Key)
>Host Key Verification Strategy: Non verifying Verification Strategy
>Availability: Keep this agent online as much as possible
>
> So, when I try to start the node, I get:
>
>
>
> [04/12/21 11:34:47] [SSH] Opening SSH connection to localhost:22. 
> [04/12/21 11:34:47] [SSH] WARNING: SSH Host Keys are not being verified. 
> Man-in-the-middle attacks may be possible against this connection. ERROR: 
> Server rejected the 1 private key(s) for  
> (credentialId:RSAKey/method:publickey)
> [04/12/21 11:34:47] [SSH] Authentication failed. Authentication failed. 
> [04/12/21 11:34:47] Launch failed - cleaning up connection 
> [04/12/21 11:34:47] [SSH] Connection closed.
>
> Thanks much!
> Eric
>

-- 
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/fd08eb85-0b55-427d-bc65-bd3ec57b4811n%40googlegroups.com.


Re: Build on all agents

2021-04-12 Thread Mark Waite
The Jenkins Pipeline DSL is extensible.  It is extended by Jenkins plugins
that you may choose to install.  The nodesByLabel step

is provided by the Pipeline utility steps
 plugin.  You'll need
to install  the Pipeline utility steps
 plugin in order to use
that step.

On Mon, Apr 12, 2021 at 9:41 AM pe...@pjksolutions.com <
p...@pjksolutions.com> wrote:

> The complete error dump
> java.lang.NoSuchMethodError: No such DSL method 'nodesByLabel'
> found among steps [archive, bat, build, catchError, checkout, deleteDir,
> dir, echo, emailext, emailextrecipients,
>  envVarsForTool, error, fileExists, findBuildScans, getContext, git,
> input, isUnix, junit, library, libraryResource,
>  load, lock, mail, milestone, node, parallel, powershell, properties,
> publishChecks, pwd, pwsh, readFile, readTrusted,
>  resolveScm, retry, script, sh, sleep, stage, stash, step, timeout,
> timestamps, tm, tool, unarchive, unstable, unstash,
>  validateDeclarativePipeline, waitUntil, warnError, withChecks,
> withContext, withCredentials, withEnv, withGradle, wrap,
>  writeFile, ws] or symbols [all, allBranchesSame, allOf, always, ant,
> antFromApache, antOutcome, antTarget, any, anyOf,
>  apiToken, architecture, archiveArtifacts, artifactManager,
> authorizationMatrix, batchFile, booleanParam, branch, brokenBuildSuspects,
>  brokenTestsSuspects, buildButton, buildDiscarder, buildDiscarders,
> buildRetention, buildUser, buildingTag, caseInsensitive,
>  caseSensitive, certificate, changeRequest, changelog, changeset,
> checkoutToSubdirectory, choice, choiceParam, cleanWs, clock,
>  command, credentials, cron, crumb, culprits, defaultFolderConfiguration,
> defaultView, demand, developers, disableConcurrentBuilds,
>  disableResume, downstream, dumb, durabilityHint, email-ext, envVars,
> envVarsFilter, environment, equals, expression, extendedEmailPublisher,
>  file, fileParam, filePath, fingerprint, fingerprints, frameOptions,
> freeStyle, freeStyleJob, fromScm, fromSource, git, gitBranchDiscovery,
>  gitHubBranchDiscovery, gitHubBranchHeadAuthority,
> gitHubExcludeArchivedRepositories, gitHubExcludePublicRepositories,
> gitHubForkDiscovery,
>  gitHubPullRequestDiscovery, gitHubSshCheckout, gitHubTagDiscovery,
> gitHubTopicsFilter, gitHubTrustContributors, gitHubTrustEveryone,
> gitHubTrustNobody,
>  gitHubTrustPermissions, gitTagDiscovery, github, githubPush, gradle,
> headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels,
> inheriting,
>  inheritingGlobal, installSource, isRestartedRun, jdk, jdkInstaller, jgit,
> jgitapache, jnlp, jobBuildDiscarder, jobName, junitTestResultStorage,
>  label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable,
> lastSuccess, legacy, legacySCM, list, local, location, logRotator,
>  loggedInUsersCanDoAnything, mailer, masterBuild, maven, maven3Mojos,
> mavenErrors, mavenGlobalConfig, mavenMojos, mavenWarnings, modernSCM,
>  myView, namedBranchesDifferent, node, nodeProperties, nonInheriting,
> none, not, overrideIndexTriggers, paneStatus, parallelsAlwaysFailFast,
>  parameters, password, pattern, permanent, pipelineTriggers, plainText,
> plugin, pollSCM, preserveStashes, projectNamingStrategy, proxy, pruneTags,
>  queueItemAuthenticator, quietPeriod, rateLimit, rateLimitBuilds,
> recipients, requestor, resourceRoot, retainOnlyVariables, run, runParam,
>  sSHLauncher, schedule, scmRetryCount, scriptApproval, scriptApprovalLink,
> search, security, shell, simpleBuildDiscarder, skipDefaultCheckout,
>  skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter,
> ssh, sshPublicKey, sshUserPrivateKey, standard, status, string, stringParam,
>  suppressAutomaticTriggering, swapSpace, tag, teamSlugFilter, text,
> textParam, timestamper, timestamperConfig, timezone, tmpSpace, toolLocation,
>  triggeredBy, unsecured, untrusted, upstream, upstreamDevelopers,
> userSeed, usernameColonPassword, usernamePassword, viewsTabBar, weather,
> withAnt,
>  zip] or globals [currentBuild, env, params, pipeline, scm]
>
> On Monday, 12 April 2021 at 16:36:38 UTC+1 pe...@pjksolutions.com wrote:
>
>> Hi Mark I tried to run it and got  java.lang.NoSuchMethodError: No such
>> DSL method 'nodesByLabel' and a lot more errors
>>
>> On Saturday, 10 April 2021 at 21:58:43 UTC+1 Mark Waite wrote:
>>
>>> The sample that I provided would be placed in a file named 'Jenkinsfile'
>>> at the root of a git repository, then a Pipeline job should be defined in
>>> Jenkins for that git repository.
>>>
>>> On Sat, Apr 10, 2021 at 2:33 PM pe...@pjksolutions.com <
>>> pe...@pjksolutions.com> wrote:
>>>
 Thanks Mark, where do I run that code ?

 On Tuesday, 6 April 2021 at 21:47:19 UTC+1 Mark Waite wrote:

> Yes.  The Jenkins Pipeline can request to build 

Node no longer working

2021-04-12 Thread eric....@gmail.com
So I had a node up to run as a user other than Jenkins.  It stopped working 
and I have no idea why.  My trouble-shooting ability has just reached its 
limit.  Anyone have any ideas for me to try?  Here are my steps to set it 
up (the RSA Key seems to be what is failing):


   1. Go to Credentials / System (shows up under Credentials) / Global 
   credentials
   2. Click Add Credentials 
   3. Kind:  SSH Username with private key 
   4. ID:  RSAKey
   Description:  RSA Key
   Username:  
   Private Key:  Select Enter directly and paste it in from results of cat 
   ~/.ssh/id_rsa (RSA should have been created without passphrase, but if you 
   created a passphrase, enter it in the Passphrase text box)
   
   5. Go to Manage Jenkins / Manage Nodes and Clouds / New Node 
   6. Name:  Node
   Description: Run as 
   # of executors: 1
   Remote root directory: /home/
   Labels: Checkout
   Usage: Only build jobs with label expressions matching this node
   Launch method: Launch agents via SSH
   Host: localhost
   Credentials:  (username RSA Key)
   Host Key Verification Strategy: Non verifying Verification Strategy
   Availability: Keep this agent online as much as possible

So, when I try to start the node, I get:

   

[04/12/21 11:34:47] [SSH] Opening SSH connection to localhost:22. 
[04/12/21 11:34:47] [SSH] WARNING: SSH Host Keys are not being verified. 
Man-in-the-middle attacks may be possible against this connection. ERROR: 
Server rejected the 1 private key(s) for  
(credentialId:RSAKey/method:publickey)
[04/12/21 11:34:47] [SSH] Authentication failed. Authentication failed. 
[04/12/21 11:34:47] Launch failed - cleaning up connection 
[04/12/21 11:34:47] [SSH] Connection closed.

Thanks much!
Eric

-- 
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/1b82bf53-b379-4342-9df8-45e904df6a1bn%40googlegroups.com.


Re: Build on all agents

2021-04-12 Thread pe...@pjksolutions.com
The complete error dump
java.lang.NoSuchMethodError: No such DSL method 'nodesByLabel' 
found among steps [archive, bat, build, catchError, checkout, deleteDir, 
dir, echo, emailext, emailextrecipients,
 envVarsForTool, error, fileExists, findBuildScans, getContext, git, input, 
isUnix, junit, library, libraryResource,
 load, lock, mail, milestone, node, parallel, powershell, properties, 
publishChecks, pwd, pwsh, readFile, readTrusted,
 resolveScm, retry, script, sh, sleep, stage, stash, step, timeout, 
timestamps, tm, tool, unarchive, unstable, unstash,
 validateDeclarativePipeline, waitUntil, warnError, withChecks, 
withContext, withCredentials, withEnv, withGradle, wrap,
 writeFile, ws] or symbols [all, allBranchesSame, allOf, always, ant, 
antFromApache, antOutcome, antTarget, any, anyOf,
 apiToken, architecture, archiveArtifacts, artifactManager, 
authorizationMatrix, batchFile, booleanParam, branch, brokenBuildSuspects,
 brokenTestsSuspects, buildButton, buildDiscarder, buildDiscarders, 
buildRetention, buildUser, buildingTag, caseInsensitive, 
 caseSensitive, certificate, changeRequest, changelog, changeset, 
checkoutToSubdirectory, choice, choiceParam, cleanWs, clock,
 command, credentials, cron, crumb, culprits, defaultFolderConfiguration, 
defaultView, demand, developers, disableConcurrentBuilds,
 disableResume, downstream, dumb, durabilityHint, email-ext, envVars, 
envVarsFilter, environment, equals, expression, extendedEmailPublisher,
 file, fileParam, filePath, fingerprint, fingerprints, frameOptions, 
freeStyle, freeStyleJob, fromScm, fromSource, git, gitBranchDiscovery,
 gitHubBranchDiscovery, gitHubBranchHeadAuthority, 
gitHubExcludeArchivedRepositories, gitHubExcludePublicRepositories, 
gitHubForkDiscovery, 
 gitHubPullRequestDiscovery, gitHubSshCheckout, gitHubTagDiscovery, 
gitHubTopicsFilter, gitHubTrustContributors, gitHubTrustEveryone, 
gitHubTrustNobody, 
 gitHubTrustPermissions, gitTagDiscovery, github, githubPush, gradle, 
headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, 
inheriting,
 inheritingGlobal, installSource, isRestartedRun, jdk, jdkInstaller, jgit, 
jgitapache, jnlp, jobBuildDiscarder, jobName, junitTestResultStorage,
 label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, 
lastSuccess, legacy, legacySCM, list, local, location, logRotator, 
 loggedInUsersCanDoAnything, mailer, masterBuild, maven, maven3Mojos, 
mavenErrors, mavenGlobalConfig, mavenMojos, mavenWarnings, modernSCM, 
 myView, namedBranchesDifferent, node, nodeProperties, nonInheriting, none, 
not, overrideIndexTriggers, paneStatus, parallelsAlwaysFailFast,
 parameters, password, pattern, permanent, pipelineTriggers, plainText, 
plugin, pollSCM, preserveStashes, projectNamingStrategy, proxy, pruneTags,
 queueItemAuthenticator, quietPeriod, rateLimit, rateLimitBuilds, 
recipients, requestor, resourceRoot, retainOnlyVariables, run, runParam, 
 sSHLauncher, schedule, scmRetryCount, scriptApproval, scriptApprovalLink, 
search, security, shell, simpleBuildDiscarder, skipDefaultCheckout,
 skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter, 
ssh, sshPublicKey, sshUserPrivateKey, standard, status, string, stringParam,
 suppressAutomaticTriggering, swapSpace, tag, teamSlugFilter, text, 
textParam, timestamper, timestamperConfig, timezone, tmpSpace, toolLocation,
 triggeredBy, unsecured, untrusted, upstream, upstreamDevelopers, userSeed, 
usernameColonPassword, usernamePassword, viewsTabBar, weather, withAnt, 
 zip] or globals [currentBuild, env, params, pipeline, scm]

On Monday, 12 April 2021 at 16:36:38 UTC+1 pe...@pjksolutions.com wrote:

> Hi Mark I tried to run it and got  java.lang.NoSuchMethodError: No such 
> DSL method 'nodesByLabel' and a lot more errors  
>
> On Saturday, 10 April 2021 at 21:58:43 UTC+1 Mark Waite wrote:
>
>> The sample that I provided would be placed in a file named 'Jenkinsfile' 
>> at the root of a git repository, then a Pipeline job should be defined in 
>> Jenkins for that git repository.
>>
>> On Sat, Apr 10, 2021 at 2:33 PM pe...@pjksolutions.com <
>> pe...@pjksolutions.com> wrote:
>>
>>> Thanks Mark, where do I run that code ?
>>>
>>> On Tuesday, 6 April 2021 at 21:47:19 UTC+1 Mark Waite wrote:
>>>
 Yes.  The Jenkins Pipeline can request to build on all available agents 
 or on all agents that match a specific label.  See nodesByLabel.

 Here's an example:

 def nodes = nodesByLabel label: '!windows'
 nodes = nodes.sort()

 Map tasks = [:]

 for (int i = 0; i < nodes.size(); i++) {
 def label = nodes[i]
 def stageName = 'Check git cache ' + 
 label.replaceAll('(-jagent)|(-ssh)|(-mwaite)|(.markwaite.net)|(-beemarkwaite)|(-jenkins)',
  
 '')
 tasks[label] = {
 node(label) {
 stage(stageName) {
 if (isUnix()) {
 sh '[ -d /var/lib/git/mwaite ] || (echo 
 /var/lib/git/mwaite 

Re: Build on all agents

2021-04-12 Thread pe...@pjksolutions.com
 Hi Mark I tried to run it and got  java.lang.NoSuchMethodError: No such 
DSL method 'nodesByLabel' and a lot more errors  

On Saturday, 10 April 2021 at 21:58:43 UTC+1 Mark Waite wrote:

> The sample that I provided would be placed in a file named 'Jenkinsfile' 
> at the root of a git repository, then a Pipeline job should be defined in 
> Jenkins for that git repository.
>
> On Sat, Apr 10, 2021 at 2:33 PM pe...@pjksolutions.com <
> pe...@pjksolutions.com> wrote:
>
>> Thanks Mark, where do I run that code ?
>>
>> On Tuesday, 6 April 2021 at 21:47:19 UTC+1 Mark Waite wrote:
>>
>>> Yes.  The Jenkins Pipeline can request to build on all available agents 
>>> or on all agents that match a specific label.  See nodesByLabel.
>>>
>>> Here's an example:
>>>
>>> def nodes = nodesByLabel label: '!windows'
>>> nodes = nodes.sort()
>>>
>>> Map tasks = [:]
>>>
>>> for (int i = 0; i < nodes.size(); i++) {
>>> def label = nodes[i]
>>> def stageName = 'Check git cache ' + 
>>> label.replaceAll('(-jagent)|(-ssh)|(-mwaite)|(.markwaite.net)|(-beemarkwaite)|(-jenkins)',
>>>  
>>> '')
>>> tasks[label] = {
>>> node(label) {
>>> stage(stageName) {
>>> if (isUnix()) {
>>> sh '[ -d /var/lib/git/mwaite ] || (echo 
>>> /var/lib/git/mwaite directory not found; exit 1)'
>>> } else {
>>> bat 'echo git cache check not implemented for 
>>> Windows'
>>> }
>>> }
>>> }
>>> }
>>> }
>>>
>>> timeout(time: 3, unit: 'MINUTES') {
>>> parallel(tasks)
>>> }
>>>
>>> Jenkins multi-configuration jobs can also build on all agents that match 
>>> a particular label, using either the elastic axis plugin or the node label 
>>> parameters plugin.
>>>
>>> Mark Waite
>>>
>>> On Tue, Apr 6, 2021 at 2:36 PM pe...@pjksolutions.com <
>>> pe...@pjksolutions.com> wrote:
>>>

 Hi all, I have one master Jenkins CI server and four slaves is is 
 possible to build a project on all agents simultaneously ?

 -- 
 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/e974d160-b2b1-41ca-b23a-5f5ef296831en%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-use...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/c8f9794a-9ece-4ff2-87db-ebe3b5afb23dn%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/d095ae49-0a64-411d-92a0-03756aa24f3dn%40googlegroups.com.


Re: how to access all classes and methods of a plugin in jenkins pipeline?

2021-04-12 Thread Ullrich Hafner
In the source code in GitHub?

You can also look for methods annotated with ExportedBean.

> Am 12.04.2021 um 10:16 schrieb jesus fernandez :
> 
> 
> where can I see that? in the javadoc I do not see any method with that 
> annotation, thoug I could use the getResults() with no problems
> El domingo, 11 de abril de 2021 a las 21:43:06 UTC+2, ullrich...@gmail.com 
> escribió:
> Due to security considerations only methods marked with @Whitelisted are 
> accessible in Groovy scripts. Does your getter have such an annotation?
> 
> 
>> Am 11.04.2021 um 19:02 schrieb jesus fernandez > >:
>> 
> 
>> I am a junior dev trying to lear about Jenkins, I have been learning on my 
>> own for a couple of months. Currently I have a pipeline (just for learning 
>> purposes) which runs static analysis on a folder, and then publish it, I 
>> have been able to send a report through email using jelly templates, from 
>> there I realized it is posbile to instantiate the classes of a plugin to use 
>> its methods so I went to the cppcheck javadoc here 
>> https://javadoc.jenkins.io/plugin/cppcheck/ 
>>  and did some trial and error 
>> so I can get some values of my report and then do something else with them 
>> something, so I had something like this in my pipeline:
>> ```
>> pipeline {
>> agent any
>> 
>> stages {
>>   stage('analysis') {
>> steps {
>>   script{
>> bat'cppcheck "E:/My_project/Source/" --xml --xml-version=2 . 2> 
>> cppcheck.xml'
>>   }
>>}
>> }
>> stage('Test'){
>>   steps {
>> script {
>>   publishCppcheck pattern:'cppcheck.xml'
>>   for (action in currentBuild.rawBuild.getActions()) {
>> def name = action.getClass().getName()
>> if (name == 'org.jenkinsci.plugins.cppcheck.CppcheckBuildAction') {
>>def cppcheckaction = action
>>def totalErrors = cppcheckaction.getResult().report.getNumberTotal()
>>println totalErrors
>>def warnings = 
>> cppcheckaction.getResult().statistics.getNumberWarningSeverity()
>>println warnings
>>   }
>> }
>>   }
>> }
>> }
>> }
>> 
>> }
>> ```
>> which output is:
>> ```
>> [Pipeline] echo
>> 102
>> [Pipeline] echo
>> 4
>> ```
>> 
>> My logic (wrongly) tells me that if I can access to the report and 
>> statistics classes like that and uses their methods getNumberTotal() and 
>> getNumberWarningSeverity() respectively, therefore I should be able to also 
>> access the ```DiffState``` class in the same way and use the ```valueOf()``` 
>> method to get an enum of the new errors. But adding this to my pipeline:
>> ```
>> def nueva = cppcheckaction.getResult().diffState.valueOf(NEW)
>> println nueva
>> ```
>> Gives me an error:
>> ```
>> org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No 
>> such field found: field org.jenkinsci.plugins.cppcheck.CppcheckBuildAction 
>> diffState
>> at 
>> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:425
>>  )
>> at 
>> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:409
>>  )
>> ...
>> ```
>> 
> 
>> -- 
>> 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/ca24b1f9-b0a8-4e81-8101-0b25f8267602n%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/9c65acbc-f199-4d99-8d96-0b37a44a4f2an%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/AB50-0B55-4A65-9095-CB657D802B4F%40gmail.com.


Re: how to access all classes and methods of a plugin in jenkins pipeline?

2021-04-12 Thread jesus fernandez

where can I see that? in the javadoc I do not see any method with that 
annotation, thoug I could use the getResults() with no problems
El domingo, 11 de abril de 2021 a las 21:43:06 UTC+2, ullrich...@gmail.com 
escribió:

> Due to security considerations only methods marked with @Whitelisted are 
> accessible in Groovy scripts. Does your getter have such an annotation?
>
> Am 11.04.2021 um 19:02 schrieb jesus fernandez :
>
> I am a junior dev trying to lear about Jenkins, I have been learning on my 
> own for a couple of months. Currently I have a pipeline (just for learning 
> purposes) which runs static analysis on a folder, and then publish it, I 
> have been able to send a report through email using jelly templates, from 
> there I realized it is posbile to instantiate the classes of a plugin to 
> use its methods so I went to the cppcheck javadoc here 
> https://javadoc.jenkins.io/plugin/cppcheck/ and did some trial and error 
> so I can get some values of my report and then do something else with them 
> something, so I had something like this in my pipeline:
> ```
> pipeline {
> agent any
>
> stages {
>   stage('analysis') {
> steps {
>   script{
> bat'cppcheck "E:/My_project/Source/" --xml --xml-version=2 . 2> 
> cppcheck.xml'
>   }
>}
> }
> stage('Test'){
>   steps {
> script {
>   publishCppcheck pattern:'cppcheck.xml'
>   for (action in currentBuild.rawBuild.getActions()) {
> def name = action.getClass().getName()
> if (name == 'org.jenkinsci.plugins.cppcheck.CppcheckBuildAction') {
>def cppcheckaction = action
>def totalErrors = cppcheckaction.getResult().report.getNumberTotal()
>println totalErrors
>def warnings = 
> cppcheckaction.getResult().statistics.getNumberWarningSeverity()
>println warnings
>   }
> }
>   } 
> }
> }
> }
>
> }
> ```
> which output is:
> ```
> [Pipeline] echo
> 102
> [Pipeline] echo
> 4
> ```
>
> My logic (wrongly) tells me that if I can access to the report and 
> statistics classes like that and uses their methods getNumberTotal() and 
> getNumberWarningSeverity() respectively, therefore I should be able to also 
> access the ```DiffState``` class in the same way and use the 
> ```valueOf()``` method to get an enum of the new errors. But adding this to 
> my pipeline:
> ```
> def nueva = cppcheckaction.getResult().diffState.valueOf(NEW)
> println nueva
> ```
> Gives me an error:
> ```
> org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No 
> such field found: field org.jenkinsci.plugins.cppcheck.CppcheckBuildAction 
> diffState
> at 
> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(
> SandboxInterceptor.java:425 )
> at 
> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(
> SandboxInterceptor.java:409 )
> ...
> ```
>
> -- 
> 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/ca24b1f9-b0a8-4e81-8101-0b25f8267602n%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/9c65acbc-f199-4d99-8d96-0b37a44a4f2an%40googlegroups.com.