Re: Git repo url

2021-07-14 Thread Ivan Fernandez Calvo
In the following repos you can find the pieces to build the script you want

https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler
https://github.com/cloudbees/jenkins-scripts

El miércoles, 14 de julio de 2021 a las 17:12:32 UTC+2, arun...@gmail.com 
escribió:

> Hi ,
>
> I'm trying to generate the report with jenkins jobs and its git repo url 
> details.
>
> Any easy way to generate it from the script console.? Please assist.
>
> Thanks in advance.
>
> Arun
>

-- 
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/f8ceedcb-ef51-4a4c-876f-81039314a186n%40googlegroups.com.


Re: Jenkins Shared Library

2021-07-14 Thread Ivan Fernandez Calvo
one more thing if you want to have those scripts shared across pipelines 
you can use the shared library.
You can define those scripts as resources in the shared library and invoke 
them directly

def stdout = bat(returnStdout: true, script: "*groovy -e 
'${libraryResource('my-script.groovy'))}'* ")

see https://www.jenkins.io/doc/book/pipeline/shared-libraries/#loading-resources
El miércoles, 14 de julio de 2021 a las 20:15:38 UTC+2, Ivan Fernandez 
Calvo escribió:

> no, it is not possible, the groovy code is executed in the Jenkins 
> controller by design, it is designed to execute simple logic of 
> orchestration logic, if you want to execute heavy logic you should do it on 
> the agents by using steps that run scripts or processes on the agent. 
>
> pipeline {
>agent { label 'scdc-generic-w10x64' }
>options {
>   timestamps()
>}
>stages {
>   stage('Log ip') {
> steps {
> script {
>bat "ipconfig -all"   // *** Gets executed on Jenkins Agent 
> ***
>def stdout = bat(returnStdout: true, script: "*groovy 
> *my-script.groovy" 
> // *** Gets executed on Jenkins Agent ***
>echo "stdout"
> }
>  }
>   }
>}
>post {
>   always {
>  cleanWs()
>   }
>}
> }
>
> the script can be whatever you want groovy, python, PowerShell, or a 
> simple binary, the only that you have to have is the script interpreter 
> installed in your Jenkins agent 
> take a look at this fantastic Jesse Glick presentation to know why 
> https://www.youtube.com/watch?v=Zeqc6--0eQw
> El martes, 13 de julio de 2021 a las 22:49:57 UTC+2, raviraj...@gmail.com 
> escribió:
>
>> I have a question regarding the execution of JSL scripts on the Jenkins 
>> Agent node. I noticed JSL scripts get executed only on Jenkins Master, is 
>> it possible to run the JSL script on Jenkins Agents?
>>
>> I have multiple stages in my Pipeline and I wish to run those stages on 
>> different Jenkins Agent nodes. 
>>
>> My primary motivation for using JSL is end-to-end Pipeline testability 
>> during development using “replay”, where I can modify Jenkinsfile as well 
>> as scripts from JSL.
>>
>> This is a snippet of my Pipeline --
>>
>> pipeline {
>>agent { label 'scdc-generic-w10x64' }
>>options {
>>   timestamps()
>>}
>>stages {
>>   stage('Log ip') {
>> steps {
>> script {
>>bat "ipconfig -all"   // *** Gets executed on Jenkins 
>> Agent ***
>>foo = jsl.foo.new(this) // foo is a Groovy class in JSL
>>foo.logIpAddress()   // *** Gets executed on Jenkins 
>> Master ***
>> }
>>  }
>>   }
>>}
>>post {
>>   always {
>>  cleanWs()
>>   }
>>}
>> }
>>
>>

-- 
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/04713271-b830-4982-a20d-478e5a857724n%40googlegroups.com.


Re: Jenkins Shared Library

2021-07-14 Thread Ivan Fernandez Calvo
no, it is not possible, the groovy code is executed in the Jenkins 
controller by design, it is designed to execute simple logic of 
orchestration logic, if you want to execute heavy logic you should do it on 
the agents by using steps that run scripts or processes on the agent. 

pipeline {
   agent { label 'scdc-generic-w10x64' }
   options {
  timestamps()
   }
   stages {
  stage('Log ip') {
steps {
script {
   bat "ipconfig -all"   // *** Gets executed on Jenkins Agent 
***
   def stdout = bat(returnStdout: true, script: "*groovy 
*my-script.groovy" 
// *** Gets executed on Jenkins Agent ***
   echo "stdout"
}
 }
  }
   }
   post {
  always {
 cleanWs()
  }
   }
}

the script can be whatever you want groovy, python, PowerShell, or a simple 
binary, the only that you have to have is the script interpreter installed 
in your Jenkins agent 
take a look at this fantastic Jesse Glick presentation to know why 
https://www.youtube.com/watch?v=Zeqc6--0eQw
El martes, 13 de julio de 2021 a las 22:49:57 UTC+2, raviraj...@gmail.com 
escribió:

> I have a question regarding the execution of JSL scripts on the Jenkins 
> Agent node. I noticed JSL scripts get executed only on Jenkins Master, is 
> it possible to run the JSL script on Jenkins Agents?
>
> I have multiple stages in my Pipeline and I wish to run those stages on 
> different Jenkins Agent nodes. 
>
> My primary motivation for using JSL is end-to-end Pipeline testability 
> during development using “replay”, where I can modify Jenkinsfile as well 
> as scripts from JSL.
>
> This is a snippet of my Pipeline --
>
> pipeline {
>agent { label 'scdc-generic-w10x64' }
>options {
>   timestamps()
>}
>stages {
>   stage('Log ip') {
> steps {
> script {
>bat "ipconfig -all"   // *** Gets executed on Jenkins Agent 
> ***
>foo = jsl.foo.new(this) // foo is a Groovy class in JSL
>foo.logIpAddress()   // *** Gets executed on Jenkins Master 
> ***
> }
>  }
>   }
>}
>post {
>   always {
>  cleanWs()
>   }
>}
> }
>
>

-- 
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/d1113336-ac16-4137-b30a-754e3005df76n%40googlegroups.com.


Re: Loop over a list of environment variables inside the environment directive at start of pipeline

2021-07-14 Thread Ivan Fernandez Calvo
the environment is a declarative block, what you are trying to make is to 
define a bunch of variables with a scriptlet block, this is far away from 
declarative.
The following code make what you want to do

pipeline {
agent any

stages {
stage('test') {
steps {
   script {
   [A:1,B:2].each { k, v ->
   env."${k}" = "${v}"
   }
   echo """
   A = ${env.A}
   B = ${env.B}
   """
   }
}
}
}
}

El miércoles, 14 de julio de 2021 a las 17:15:29 UTC+2, 
fakemai...@gmail.com escribió:

> I haven't found any examples of how to do this
>
> instead of this:
>
> pipeline {
>
> agent { label 'docker' }
>
> environment {
>
> ENV1 = 'default'
>
> ENV2 = 'default'
>
> }
>
>
> I want to do this:
>
> pipeline {
>
> agent { label 'docker' }
>
> environment {
>
> for (env in envs) {
>
>env.name = env.value
>
> }
>
> }
>
>
> maybe I can generate a map before the `pipeline{}` directive and pass it 
> to `environment{}` somehow? I dont want to do this inside of a stage I want 
> this at the top level environment directive for all stages
>

-- 
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/731604df-3a72-4c54-ba63-d5626a9e437bn%40googlegroups.com.


Re: Ansible Tower Plugin communication issue between Jenkins and AWX

2021-07-14 Thread Richard Lund
Bump - still hoping someone can help me with this.

Thanks!

On Thursday, May 13, 2021 at 7:15:38 AM UTC-5 Richard Lund wrote:

> Hi.
>
> We use Jenkins to build our apps and then start AWX playbooks to deploy 
> the built app to Openshift. For that, we use the Ansible Tower plugin in 
> Jenkins and access it through pipeline code.
>
> Randomly, we get what looks like communication issues between AWX and 
> Jenkins.
>
> The pipeline will fail with the error:
>
> *"ERROR: Failed to get job status from Tower"*
>
> Often it will add a *503* error with the same message.
>
> I have checked all the Jenkins logs I can get to, but I can't find more 
> details on this.
>
> AWX is deployed in Openshift as Stateful Set, and I have scanned through 
> awx:celery and awx:web to try and track this down, but the only mention of 
> a 503 is this:
>
> [Ansible-Tower] Building GET request to https://awx/api/v2/jobs/57602/
> [Ansible-Tower] Forcing cert trust
> [Ansible-Tower] Request completed with (503)
> [Ansible-Tower] Deleting oAuth token 15396 for awx
> [Ansible-Tower] Forcing cert trust
> [Ansible-Tower] Calling for oAuth token delete at 
> https://awx/api/v2/tokens/15396/
> [Ansible-Tower] Request completed with (200)
>
> This seems to happen the most while AWX is waiting for Openshift to finish 
> deployment. The job ALWAYS finishes normally - yet Jenkins receives this 
> error and fails the pipeline even though everything else worked. It also 
> seems to happen on apps that take the longest to deploy - maybe 10-15 
> minutes.
>
> We had this issue last year, then it went away, now it came back, and it 
> is affecting our work when pipelines are marked as failed and we have to 
> constantly double-check if the job actually finished or not.
>
> I have restarted Jenkins and AWX, and I have updated the Ansible Tower 
> plugin to the newest version - no change.
>
> AWX is on version 9.0.0.0 (installed in Openshift) with Ansible 2.8.5.
>
> Jenkins is on version 2.235.1 (also installed in Openshift).
>
> Ansible Tower Plugin is on version 0.16.0.
>
> I'd appreciate any help or pointers you can provide that can help me track 
> this down.
>
> 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/4d8c1e1e-0d12-49e3-8ff3-77c2974d0c51n%40googlegroups.com.


Loop over a list of environment variables inside the environment directive at start of pipeline

2021-07-14 Thread fakemai...@gmail.com


I haven't found any examples of how to do this

instead of this:

pipeline {

agent { label 'docker' }

environment {

ENV1 = 'default'

ENV2 = 'default'

}


I want to do this:

pipeline {

agent { label 'docker' }

environment {

for (env in envs) {

   env.name = env.value

}

}


maybe I can generate a map before the `pipeline{}` directive and pass it to 
`environment{}` somehow? I dont want to do this inside of a stage I want 
this at the top level environment directive for all stages

-- 
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/e49ea9ec-0ec7-4537-bef0-c900bdea6740n%40googlegroups.com.


Git repo url

2021-07-14 Thread arun B
Hi ,

I'm trying to generate the report with jenkins jobs and its git repo url 
details.

Any easy way to generate it from the script console.? Please assist.

Thanks in advance.

Arun

-- 
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/4a01a213-3e47-4edf-917f-5b1bdb6c752bn%40googlegroups.com.


Re: "configure" fails with major.minor version issue

2021-07-14 Thread 'Harry G.' via Jenkins Users
Hi Bob,

we also have legacy projects where developers still need Java 1.6.
But maybe there is a misunderstanding, you don't need to run Jenkins 
istself under that version then, even not the agents.
You just need to have a JDK1.6 somewhere available on your agent and 
configred as tool for your agent, then select this JDK in the build 
job/pipeline script.

Harald

bob...@gmail.com schrieb am Dienstag, 13. Juli 2021 um 20:27:59 UTC+2:

> I downgraded script-security to a version that runs in 1.6 and the problem 
> is now fixed. Thanks for your help!
>
> On Monday, July 12, 2021 at 10:11:03 PM UTC+3 kuisat...@gmail.com wrote:
>
>> I guess you update some plugins one of those plugins is the script 
>> security plugin, which in the version you update works on Jenkins 1.609 but 
>> does not support Java 6. I will tell you that the faster solution is to 
>> restore the plugins folder from a backup that you have before the changes 
>> on the plugins, if you do not have that backup you have to review all hpi 
>> files in the plugins folder, and check the file MANIFEST.MF inside the hip 
>> file, it is a zip, in that manifest, you have to check the value in 
>> "Minimum-Java-Version:", all the plugins that require 1.8 are not valid for 
>> your installation. But again you have a security clock boom on that 
>> instance a Java version from 2013 and a Jenkins core from 2015.
>>
>> El lunes, 12 de julio de 2021 a las 20:21:51 UTC+2, bob...@gmail.com 
>> escribió:
>>
>>> On our current production server we run 1.609 with Java 1.6. It is very 
>>> very old but it's not my decision to upgrade it, it's the Dev Team's. This 
>>> version and this Java are indeed compatible, Jenkins runs fine on our 
>>> current server.
>>>
>>> I therefore need to revert to 1.6 anything that has, inadvertently, gone 
>>> to 1.8. Please help me with that.  To start with, am I running into 1.8 
>>> plugins, or 1.8 artifacts? 
>>>
>>> Some sites suggest that this is a browser/Javascript issue. I'm at a 
>>> loss.
>>>
>>> On Monday, July 12, 2021 at 7:25:52 PM UTC+3 kuisat...@gmail.com wrote:
>>>
 "Unsupported major.minor version 52.0" means that you need to run on 
 Java 8 (see 
 https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi/
 )

 the Java 6 version you are using is EOL since 2013 (see 
 https://en.wikipedia.org/wiki/Java_version_history) and your Jenkins 
 version was released in 2015 (see 
 https://www.jenkins.io/changelog-stable/#v1.609.3) so I don't know if 
 that version can run on Java 6, I dunno why you are trying to use 
 something 
 old and with tons of issues resolved in the latest version on an outdated 
 and without support Java version, but sounds like a no-good idea.

 El lunes, 12 de julio de 2021 a las 16:33:20 UTC+2, bob...@gmail.com 
 escribió:

> Let me add that the system property java.class.version  on both 
> servers new (source and copy) has the value 50.0
>
> So it seems I need to get rid of all 52.0 stuff.
>
>
>
> On Monday, July 12, 2021 at 4:30:53 PM UTC+3 GI D wrote:
>
>> On a copied installation of Jenkins 1.609 to a new server, I notice 
>> that when I select a build and click "configure", I get a greyed-out 
>> config 
>> page with "LOADING" as a watermark that never goes away. At the same 
>> time I 
>> see in catalina.out lots of errors such as this:
>>
>> Jul 12, 2021 4:15:20 PM hudson.ExpressionFactory2$JexlExpression 
>> evaluate
>> WARNING: Caught exception evaluating: d.helpFile in 
>> /jenkins/job/platform%20set%20branch%20name/configure. Reason: jav
>> a.lang.reflect.InvocationTargetException
>> 
>> 
>> Caused by: java.lang.UnsupportedClassVersionError: 
>> org/jenkinsci/plugins/scriptsecurity/sandbox/RejectedAccessException : 
>> Unsupported major.minor version 52.0
>>
>> I think the reason is that, for a few days, I was running the new 
>> Jenkins with a slightly newer Java version (1.6.0_41 rather than 
>> 1.6.0_30). 
>> Now I have made sure I run it with _30. During this short period this 
>> particular build has been executed a few times. However I do get the 
>> same 
>> problem on other builds that have not executed on this new server.
>>
>> Almost all errors (or warnings if you will) are about the 
>> script-security plugin. 
>>
>> Please advise.
>>
>> - George
>>
>>

-- 
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/071b6729-2d51-4d21-89d5-e38d1bb3d8acn%40googlegroups.com.


Re: update 2.289.2 ldap not working

2021-07-14 Thread Daniel Beck
On Wed, Jul 7, 2021 at 3:13 PM vla...@gmail.com  wrote:

> the config.xml with my old ldap configuration is coming back at each
> restart => what is this mechanism? thanks in advance


That's not built in.

Check for the presence of Groovy hook directories:
https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/
If you're using https://plugins.jenkins.io/configuration-as-code/ check its
configuration.
There may also be mechanisms external to Jenkins that restore a specific
configuration.

-- 
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/CAMo7PtK9yWxXp1KqpuJ5N3JQxwfRSuYOTJHyEURMQqG%3DcprJJA%40mail.gmail.com.