Re: how can I get the value of a global variable within a function in a pipeline?

2021-02-11 Thread Victor Martinez
You can simplify it quite a bit with the post stage event 
https://www.jenkins.io/doc/book/pipeline/syntax/#post

The example pipeline uses the post *stages* section, you can use the one 
specific the stage 3

Another example can be found in 
https://www.jenkins.io/blog/2017/02/15/declarative-notifications/

Environment variables within an environment section are immutable, though 
you can use the script closure with the env map to set a new env variable 
that can be override

For instance:

stage(“stage 3”) {
  steps{
 script{
   env.FAILED_STAGE=env.STAGE_NAME
 }
 error ...
  }
}

Cheers





See 

On Thursday, 11 February 2021 at 17:56:40 UTC jesusfern...@gmail.com wrote:

>
> I have a declarative pipeline with a few steps. at the end I send a message 
> to slack with some statistics of the compilation times and some more 
> information. I want to send in case it fails the stage at which it fails. I 
> have set a global variable but the function does not seem to be able to read 
> its value. This is a simplified version of what I have: 
>
> ```
> def FAILED_STAGE
>
> def sendSlackNotifcation() 
> {
> if ( currentBuild.currentResult == "SUCCESS" ) {
>
> slackSend message: "${currentBuild.result}", channel: '#jenkins_bot2'
> }
> 
> else {
>
> slackSend color : "#FF", message: "${FAILED_STAGE}", channel: 
> '#jenkins_bot2'
>
> }
> }
>
> pipeline {
> agent any
>
> stages {
> stage('stage1') {
> steps{
> echo "stage1"
> }
> } 
> 
> stage('stage2') {
> steps{
> echo "stage2"
> }
> }
> 
> stage("Stage 3") {
> steps {
> script {
> FAILED_STAGE=env.STAGE_NAME
> echo "${FAILED_STAGE}"
> error "failed for some reason."
> }
> }
> }
> }
> post {
> failure {
> sendSlackNotifcation()
> }
> }
>
> }
> ```
> And this is the output I get:
> ```
> 13:38:53  [Pipeline] {
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (stage1)
> 13:38:53  [Pipeline] echo
> 13:38:53  stage1
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // stage
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (stage2)
> 13:38:53  [Pipeline] echo
> 13:38:53  stage2
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // stage
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (Stage 3)
> 13:38:53  [Pipeline] script
> 13:38:53  [Pipeline] {
> 13:38:53  [Pipeline] echo
> 13:38:53  Stage 3
> 13:38:53  [Pipeline] error
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // script
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // stage
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (Declarative: Post Actions)
> 13:38:53  Error when executing failure post condition:
>
> 13:38:53  groovy.lang.MissingPropertyException: No such property: 
> FAILED_STAGE for class: WorkflowScript
> ```
>

-- 
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/196f4d91-2b7b-441f-b080-f54595c71439n%40googlegroups.com.


how can I get the value of a global variable within a function in a pipeline?

2021-02-11 Thread Jesus Fernandez
I have a declarative pipeline with a few steps. at the end I send a message to 
slack with some statistics of the compilation times and some more information. 
I want to send in case it fails the stage at which it fails. I have set a 
global variable but the function does not seem to be able to read its value. 
This is a simplified version of what I have: 

```
def FAILED_STAGE

def sendSlackNotifcation() 
{
if ( currentBuild.currentResult == "SUCCESS" ) {
slackSend message: "${currentBuild.result}", channel: '#jenkins_bot2'
}

else {
slackSend color : "#FF", message: "${FAILED_STAGE}", channel: 
'#jenkins_bot2'

}
}

pipeline {
agent any

stages {
stage('stage1') {
steps{
echo "stage1"
}
} 

stage('stage2') {
steps{
echo "stage2"
}
}

stage("Stage 3") {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
echo "${FAILED_STAGE}"
error "failed for some reason."
}
}
}
}
post {
failure {
sendSlackNotifcation()
}
}

}
```
And this is the output I get:
```
13:38:53  [Pipeline] {
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (stage1)
13:38:53  [Pipeline] echo
13:38:53  stage1
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // stage
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (stage2)
13:38:53  [Pipeline] echo
13:38:53  stage2
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // stage
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (Stage 3)
13:38:53  [Pipeline] script
13:38:53  [Pipeline] {
13:38:53  [Pipeline] echo
13:38:53  Stage 3
13:38:53  [Pipeline] error
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // script
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // stage
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (Declarative: Post Actions)
13:38:53  Error when executing failure post condition:
13:38:53  groovy.lang.MissingPropertyException: No such property: FAILED_STAGE 
for class: WorkflowScript
```

-- 
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/be75d622-ca44-47af-a06c-99464b802bbcn%40googlegroups.com.


Re: how can I get the value of a global variable within a function in a pipeline?

2021-02-11 Thread Ven H
https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables

Regards,
Venkatesh


On Thu, Feb 11, 2021 at 11:44 PM jesus fernandez <
jesusfernandez0...@gmail.com> wrote:

> Thanks for replying, any example or any link where to get information
> about how to do so? I am a bit new to Jenkins
>
> El jueves, 11 de febrero de 2021 a las 19:11:24 UTC+1, venh...@gmail.com
> escribió:
>
>> Try defining it inside the "environment" stage / step.
>>
>> Regards,
>> Venkatesh
>>
>>
>> On Thu, Feb 11, 2021 at 11:26 PM jesus fernandez 
>> wrote:
>>
>>>
>>> I have a declarative pipeline with a few steps. at the end I send a message 
>>> to slack with some statistics of the compilation times and some more 
>>> information. I want to send in case it fails the stage at which it fails. I 
>>> have set a global variable but the function does not seem to be able to 
>>> read its value. This is a simplified version of what I have:
>>>
>>> ```
>>> def FAILED_STAGE
>>>
>>> def sendSlackNotifcation()
>>> {
>>> if ( currentBuild.currentResult == "SUCCESS" ) {
>>>
>>> slackSend message: "${currentBuild.result}", channel: 
>>> '#jenkins_bot2'
>>> }
>>>
>>> else {
>>>
>>> slackSend color : "#FF", message: "${FAILED_STAGE}", channel: 
>>> '#jenkins_bot2'
>>>
>>> }
>>> }
>>>
>>> pipeline {
>>> agent any
>>>
>>> stages {
>>> stage('stage1') {
>>> steps{
>>> echo "stage1"
>>> }
>>> }
>>>
>>> stage('stage2') {
>>> steps{
>>> echo "stage2"
>>> }
>>> }
>>>
>>> stage("Stage 3") {
>>> steps {
>>> script {
>>> FAILED_STAGE=env.STAGE_NAME
>>> echo "${FAILED_STAGE}"
>>> error "failed for some reason."
>>> }
>>> }
>>> }
>>> }
>>> post {
>>> failure {
>>> sendSlackNotifcation()
>>> }
>>> }
>>>
>>> }
>>> ```
>>> And this is the output I get:
>>> ```
>>> 13:38:53  [Pipeline] {
>>> 13:38:53  [Pipeline] stage
>>> 13:38:53  [Pipeline] { (stage1)
>>> 13:38:53  [Pipeline] echo
>>> 13:38:53  stage1
>>> 13:38:53  [Pipeline] }
>>> 13:38:53  [Pipeline] // stage
>>> 13:38:53  [Pipeline] stage
>>> 13:38:53  [Pipeline] { (stage2)
>>> 13:38:53  [Pipeline] echo
>>> 13:38:53  stage2
>>> 13:38:53  [Pipeline] }
>>> 13:38:53  [Pipeline] // stage
>>> 13:38:53  [Pipeline] stage
>>> 13:38:53  [Pipeline] { (Stage 3)
>>> 13:38:53  [Pipeline] script
>>> 13:38:53  [Pipeline] {
>>> 13:38:53  [Pipeline] echo
>>> 13:38:53  Stage 3
>>> 13:38:53  [Pipeline] error
>>> 13:38:53  [Pipeline] }
>>> 13:38:53  [Pipeline] // script
>>> 13:38:53  [Pipeline] }
>>> 13:38:53  [Pipeline] // stage
>>> 13:38:53  [Pipeline] stage
>>> 13:38:53  [Pipeline] { (Declarative: Post Actions)
>>> 13:38:53  Error when executing failure post condition:
>>>
>>> 13:38:53  groovy.lang.MissingPropertyException: No such property: 
>>> FAILED_STAGE for class: WorkflowScript
>>> ```
>>>
>>> --
>>> 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/91e7dbcd-c806-4d55-bc31-bc9a9ad4057cn%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/f2756185-f00c-4bf8-a382-f7659da29ca6n%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/CAPp28epL%2BCgm8yvzX0qNMNZbQ0Odxj5xaRsgJz73i40pQ5tRwg%40mail.gmail.com.


Multibranch pipelines and jobDSL

2021-02-11 Thread kuisathaverat
Hi,

We are trying to move to jobDSL our job definitions, at this point we have
hit an issue that I am not sure we can move forward.
To define the Multibranch Pipeline jobs everithing works fine except the
pull request discovery settings,
Because ForkPullRequestDiscoveryTrait and OriginPullRequestDiscoveryTrait
uses the same symbol we have to use a workaround to configure branch
discovery.
This workaround is to use a `configure` block in the jobDSL definition to
set the proper settings.
This workaround works until jobDSL 1.75, after that it not possible to use
the configuration block due to a sandbox issue (see
https://issues.jenkins.io/browse/JENKINS-63788)
Does anyone found another workaround valid?


this is our current jobDSL definition, noted the `configure` block is
commented

multibranchPipelineJob('test-mbp') {
  primaryView('All')
  displayName('Job test-mbp')
  description('Job test-mbp')
  orphanedItemStrategy {
discardOldItems {
  numToKeep(20)
  daysToKeep(7)
}
  }
  branchSources {
branchSource {
  source {
github {
  id('apm-shared/oblt-test-env/test-bmp') // IMPORTANT: use a
constant and unique identifier
  credentialsId('my-id')
  repoOwner('owner')
  repository('my-repo')
  repositoryUrl('https://github.com/owner/repo.git')
  configuredByUrl(true)
  // The behaviours control what is discovered from the GitHub
repository.
  traits {
checkoutOptionTrait {
  extension {
// Specify a timeout (in minutes) for checkout.
timeout(15)
  }
}
cleanBeforeCheckoutTrait {
  extension {
// Deletes untracked submodules and any other
subdirectories which contain .git directories.
deleteUntrackedNestedRepositories(true)
  }
}
cloneOptionTrait {
  extension {
// Perform shallow clone, so that git will not download the
history of the project, saving time and disk space when you just want to
access the latest version of a repository.
shallow(true)
// Deselect this to perform a clone without tags, saving
time and disk space when you just want to access what is specified by the
refspec.
noTags(false)
// Specify a folder containing a repository that will be
used by Git as a reference during clone operations.
reference("/var/lib/jenkins//apm-pipeline-library.git")
// Specify a timeout (in minutes) for clone and fetch
operations.
timeout(15)
// Set shallow clone depth, so that git will only download
recent history of the project, saving time and disk space when you just
want to access the latest commits of a repository.
depth(5)
// Perform initial clone using the refspec defined for the
repository.
honorRefspec(false)
  }
}
// Discovers branches on the repository.
//
https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTrait.java#L55-L70
gitHubBranchDiscovery{
  // Determines which branches are discovered.
  strategyId(1)
}
// Discovers tags on the repository.
gitHubTagDiscovery()
// filers heads
headRegexFilter {
  // A Java regular expression to restrict the names.
  regex('(master|main|PR-.*|\\d+\\.x)')
}
// ignore push
//ignoreOnPushNotificationTrait()
// Defines a custom context label to be sent as part of Github
Status notifications for this project.
notificationContextTrait {
  // The text of the context label for Github status
notifications.
  contextLabel('my-ci-context')
  // Appends the relevant suffix to the context label based on
the build type.
  typeSuffix(true)
}
wipeWorkspaceTrait()
  }
}
buildStrategies {
  buildChangeRequests {
// If the change request / pull request is a merge, there are
two reasons for a revision change: The origin of the change request may
have changed The target of the change request may ha
ignoreTargetOnlyChanges(false)
// Some sources can permit change request / pull request from
external entities.
ignoreUntrustedChanges(true)
  }
  // Builds regular branches whenever a change is detected.
  buildRegularBranches()
  // Builds tags (subject to a configurable tag age time window)
  buildTags {
atLeastDays('-1')
// The number of days since the tag was created after which it
is no longer 

Re: how can I get the value of a global variable within a function in a pipeline?

2021-02-11 Thread jesus fernandez
Thanks for replying, any example or any link where to get information about 
how to do so? I am a bit new to Jenkins

El jueves, 11 de febrero de 2021 a las 19:11:24 UTC+1, venh...@gmail.com 
escribió:

> Try defining it inside the "environment" stage / step.
>
> Regards,
> Venkatesh
>
>
> On Thu, Feb 11, 2021 at 11:26 PM jesus fernandez  
> wrote:
>
>>
>> I have a declarative pipeline with a few steps. at the end I send a message 
>> to slack with some statistics of the compilation times and some more 
>> information. I want to send in case it fails the stage at which it fails. I 
>> have set a global variable but the function does not seem to be able to read 
>> its value. This is a simplified version of what I have: 
>>
>> ```
>> def FAILED_STAGE
>>
>> def sendSlackNotifcation() 
>> {
>> if ( currentBuild.currentResult == "SUCCESS" ) {
>>
>> slackSend message: "${currentBuild.result}", channel: '#jenkins_bot2'
>> }
>> 
>> else {
>>
>> slackSend color : "#FF", message: "${FAILED_STAGE}", channel: 
>> '#jenkins_bot2'
>>
>> }
>> }
>>
>> pipeline {
>> agent any
>>
>> stages {
>> stage('stage1') {
>> steps{
>> echo "stage1"
>> }
>> } 
>> 
>> stage('stage2') {
>> steps{
>> echo "stage2"
>> }
>> }
>> 
>> stage("Stage 3") {
>> steps {
>> script {
>> FAILED_STAGE=env.STAGE_NAME
>> echo "${FAILED_STAGE}"
>> error "failed for some reason."
>> }
>> }
>> }
>> }
>> post {
>> failure {
>> sendSlackNotifcation()
>> }
>> }
>>
>> }
>> ```
>> And this is the output I get:
>> ```
>> 13:38:53  [Pipeline] {
>> 13:38:53  [Pipeline] stage
>> 13:38:53  [Pipeline] { (stage1)
>> 13:38:53  [Pipeline] echo
>> 13:38:53  stage1
>> 13:38:53  [Pipeline] }
>> 13:38:53  [Pipeline] // stage
>> 13:38:53  [Pipeline] stage
>> 13:38:53  [Pipeline] { (stage2)
>> 13:38:53  [Pipeline] echo
>> 13:38:53  stage2
>> 13:38:53  [Pipeline] }
>> 13:38:53  [Pipeline] // stage
>> 13:38:53  [Pipeline] stage
>> 13:38:53  [Pipeline] { (Stage 3)
>> 13:38:53  [Pipeline] script
>> 13:38:53  [Pipeline] {
>> 13:38:53  [Pipeline] echo
>> 13:38:53  Stage 3
>> 13:38:53  [Pipeline] error
>> 13:38:53  [Pipeline] }
>> 13:38:53  [Pipeline] // script
>> 13:38:53  [Pipeline] }
>> 13:38:53  [Pipeline] // stage
>> 13:38:53  [Pipeline] stage
>> 13:38:53  [Pipeline] { (Declarative: Post Actions)
>> 13:38:53  Error when executing failure post condition:
>>
>> 13:38:53  groovy.lang.MissingPropertyException: No such property: 
>> FAILED_STAGE for class: WorkflowScript
>> ```
>>
>> -- 
>> 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/91e7dbcd-c806-4d55-bc31-bc9a9ad4057cn%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/f2756185-f00c-4bf8-a382-f7659da29ca6n%40googlegroups.com.


Re: how can I get the value of a global variable within a function in a pipeline?

2021-02-11 Thread Ven H
Try defining it inside the "environment" stage / step.

Regards,
Venkatesh


On Thu, Feb 11, 2021 at 11:26 PM jesus fernandez <
jesusfernandez0...@gmail.com> wrote:

>
> I have a declarative pipeline with a few steps. at the end I send a message 
> to slack with some statistics of the compilation times and some more 
> information. I want to send in case it fails the stage at which it fails. I 
> have set a global variable but the function does not seem to be able to read 
> its value. This is a simplified version of what I have:
>
> ```
> def FAILED_STAGE
>
> def sendSlackNotifcation()
> {
> if ( currentBuild.currentResult == "SUCCESS" ) {
>
> slackSend message: "${currentBuild.result}", channel: '#jenkins_bot2'
> }
>
> else {
>
> slackSend color : "#FF", message: "${FAILED_STAGE}", channel: 
> '#jenkins_bot2'
>
> }
> }
>
> pipeline {
> agent any
>
> stages {
> stage('stage1') {
> steps{
> echo "stage1"
> }
> }
>
> stage('stage2') {
> steps{
> echo "stage2"
> }
> }
>
> stage("Stage 3") {
> steps {
> script {
> FAILED_STAGE=env.STAGE_NAME
> echo "${FAILED_STAGE}"
> error "failed for some reason."
> }
> }
> }
> }
> post {
> failure {
> sendSlackNotifcation()
> }
> }
>
> }
> ```
> And this is the output I get:
> ```
> 13:38:53  [Pipeline] {
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (stage1)
> 13:38:53  [Pipeline] echo
> 13:38:53  stage1
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // stage
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (stage2)
> 13:38:53  [Pipeline] echo
> 13:38:53  stage2
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // stage
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (Stage 3)
> 13:38:53  [Pipeline] script
> 13:38:53  [Pipeline] {
> 13:38:53  [Pipeline] echo
> 13:38:53  Stage 3
> 13:38:53  [Pipeline] error
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // script
> 13:38:53  [Pipeline] }
> 13:38:53  [Pipeline] // stage
> 13:38:53  [Pipeline] stage
> 13:38:53  [Pipeline] { (Declarative: Post Actions)
> 13:38:53  Error when executing failure post condition:
>
> 13:38:53  groovy.lang.MissingPropertyException: No such property: 
> FAILED_STAGE for class: WorkflowScript
> ```
>
> --
> 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/91e7dbcd-c806-4d55-bc31-bc9a9ad4057cn%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/CAPp28eqF44WGYh0b-61Eji_TyTrceyvqp78ti4o%3Dx7i-eEmOjQ%40mail.gmail.com.


how can I get the value of a global variable within a function in a pipeline?

2021-02-11 Thread jesus fernandez
I have a declarative pipeline with a few steps. at the end I send a message to 
slack with some statistics of the compilation times and some more information. 
I want to send in case it fails the stage at which it fails. I have set a 
global variable but the function does not seem to be able to read its value. 
This is a simplified version of what I have: 

```
def FAILED_STAGE

def sendSlackNotifcation() 
{
if ( currentBuild.currentResult == "SUCCESS" ) {
slackSend message: "${currentBuild.result}", channel: '#jenkins_bot2'
}

else {
slackSend color : "#FF", message: "${FAILED_STAGE}", channel: 
'#jenkins_bot2'

}
}

pipeline {
agent any

stages {
stage('stage1') {
steps{
echo "stage1"
}
} 

stage('stage2') {
steps{
echo "stage2"
}
}

stage("Stage 3") {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
echo "${FAILED_STAGE}"
error "failed for some reason."
}
}
}
}
post {
failure {
sendSlackNotifcation()
}
}

}
```
And this is the output I get:
```
13:38:53  [Pipeline] {
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (stage1)
13:38:53  [Pipeline] echo
13:38:53  stage1
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // stage
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (stage2)
13:38:53  [Pipeline] echo
13:38:53  stage2
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // stage
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (Stage 3)
13:38:53  [Pipeline] script
13:38:53  [Pipeline] {
13:38:53  [Pipeline] echo
13:38:53  Stage 3
13:38:53  [Pipeline] error
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // script
13:38:53  [Pipeline] }
13:38:53  [Pipeline] // stage
13:38:53  [Pipeline] stage
13:38:53  [Pipeline] { (Declarative: Post Actions)
13:38:53  Error when executing failure post condition:
13:38:53  groovy.lang.MissingPropertyException: No such property: FAILED_STAGE 
for class: WorkflowScript
```

-- 
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/91e7dbcd-c806-4d55-bc31-bc9a9ad4057cn%40googlegroups.com.


Can pipelines and stages be nested in a dependency graph? Or is there a better alternative.

2021-02-11 Thread Anil
I have a number of tasks and some are dependent on others for completion.
If task A is dependent on tasks B and C completing, then B and C will be 
child tasks of A.
It is also possible that task D is dependent on task B and then we have a 
DAG.
So they will form a dependency graph (Directed Acyclic Graph)
Can I have a pipeline script with nested pipelines and jobs?
Or is there a better alternative.

-- 
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/96d897cf-35f5-4069-a994-b31396b4eea8n%40googlegroups.com.


Jenkins Plugins Versions and their compatible versions

2021-02-11 Thread Balu Balaji
Hi All, 
I am trying to find the Jenkins plugins list and their compatibility to the 
Jenkins version 2.222.4 version. 

Could you please help me with the Jenkins 2.222.4 compatible below Plugins 
versions?

*LDAP*

*ssh-agent*

*apache-httpcomponents-client-4-api*

*bouncycastle-api*

*branch-api*

*pipeline-model-declarative-agent*

*pipeline-rest-api*

*pipeline-stage-view*

*token-macro*

*variant*

*workflow-basic-steps*

*workflow-durable-task-step*
*workflow-scm-step*

For all the above plugins, what are the compatible versions with Jenkins 
2.222.4 version?
For example, what is the branch-api plugin version which is compatible with 
Jenkins 2.222.4 version? and so on.


Thanks
Balaji Sivaramagari

-- 
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/2bfb3baf-0f5a-44b0-996f-90a031b457f6n%40googlegroups.com.


nginx pipeline

2021-02-11 Thread pr1
Hello,
I am currently working on an OpenShift (=~ Kubernetes) project with a pod 
containing nginx. Originally, I installed the web server using the 
OpenShift Catalog. Then a DevOps suggested that I create a pipeline in 
Jenkins which would build (?) nginx. How do you build a non-Java project 
with Jenkins? Do I need to build nginx (make, make install, ...), in my 
case? Can't I just set up Jenkins to retrieve, say, a Docker file 
containing nginx from a repository?
Any help would be much appreciated.
Many thanks.
pr1

-- 
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/646f6d11-7931-4e9d-bbfa-ac96a708b18dn%40googlegroups.com.


Re: Jenkins URL https://.com/ is not working(502 Bad Gateway)

2021-02-11 Thread 'Dirk Heinrichs' via Jenkins Users
Am Donnerstag, den 11.02.2021, 03:36 -0800 schrieb anilkumar panditi:

> Could you please give the docker run command to use 443 ,

I could (and did, see my previous responses), but I doubt it would make
sense, since I don't think the Jenkins inside your container is
configured to use SSL, or is it?

If you want to protect your Jenkins setup with SSL, I'd recommend
running an Apache2 or NGinx webserver as a reverse proxy in front of it
to handle the SSL stuff (see Jenkins documentation). This could be
running directly on your Docker host, inside a container or even on a
remote machine, but that's up to you.

As long as you don't have this set up, it doesn't make sense to try to
connect using https://. Please first try to connect w/o SSL to confirm
it's working, by using "curl http://:8080" from a remote
host. Then setup SSL.

BTW: If you change your "-p 8080:8080" to "-p 80:8080", to map the
hosts port 80 to the containers port 8080, you can omit the port number
when running your curl command, since 80 is the standard port for
http:// (the command becomes just "curl 
http://>".

HTH...

Dirk

-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Email: dhein...@opentext.com
Website: www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu
Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn,
Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the material in
this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-
Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser Mail sind nicht gestattet.

-- 
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/8e9c9c26e7f802d10521db8cd27e9f957cfdb985.camel%40opentext.com.


signature.asc
Description: This is a digitally signed message part


Re: Jenkins URL https://.com/ is not working(502 Bad Gateway)

2021-02-11 Thread anilkumar panditi
Hi Dirk,
Could you please give the docker run command to use 443 ,

Thanks
Anil Panditi
On Wednesday, 10 February 2021 at 17:39:44 UTC+5:30 dheinric wrote:

> Am Mittwoch, den 10.02.2021, 04:00 -0800 schrieb anilkumar panditi:
>
> docker run --name myjenkins -d -u root -p 8080:8080 -p 5:5 -v 
> $(which docker):/usr/bin/docker -v /jenkins:/var/jenkins_home -v 
> /var/run/docker.sock:/var/run/docker.sock  myjenkins
>
> And i curled from other host and it gets connected and throwing 502 bad 
> gateway.
>
>
> From your first mail, you where running curl with "https://...;, 
>  which means port 443. I see no mapping of port 443 in the 
> above command. Try running curl with "http://...:8080;.
>
> HTH...
>
> Dirk
>
> -- 
>
> *Dirk Heinrichs*
> Senior Systems Engineer, Delivery Pipeline
> OpenText ™ Discovery | Recommind
> *Phone*: +49 2226 15966 18 <+49%202226%201596618>
> *Email*: dhei...@opentext.com
> *Website*: www.recommind.de
> Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
> Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, 
> Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
> This e-mail may contain confidential and/or privileged information. If you 
> are not the intended recipient (or have received this e-mail in error) 
> please notify the sender immediately and destroy this e-mail. Any 
> unauthorized copying, disclosure or distribution of the material in this 
> e-mail is strictly forbidden
> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte 
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail 
> irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und 
> vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte 
> Weitergabe dieser Mail sind nicht gestattet.
>

-- 
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/eb43cbb6-d0ef-4d54-a9a5-227d9462e352n%40googlegroups.com.


Re: Set-Variable : Cannot process command because of one or more missing mandatory parameters: Name.

2021-02-11 Thread Amedee Van Gasse
That would actually be great and very much appreciated.


I've been down the rabbit hole a bit further and found something that may 
be of interest.

>From what I've seen from the error, Jenkins sends compound shell commands 
to the node, with "&&" as pipeline chain operator.
"&&" has the same function in Bash as well as in MS-DOS.
PowerShell Windows (up to version 5 I guess) doesn't know '&&', there you 
have to use '-and'.
However, PowerShell 7 (PowerShell Core, the open source cross-platform 
version) does implement pipeline chain operators.
See 
https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-70?view=powershell-7

I don't know if that will solve all of the issues with PowerShell, but it's 
definitely worth giving a shot.
I'll try it out and report back here.

On Wednesday, February 10, 2021 at 8:05:15 PM UTC+1 slide wrote:

> FYI, I started to look at this again and will hopefully have a PR soon.
>
> On Tue, Feb 9, 2021, 08:07 Slide  wrote:
>
>> That will cause problems, the ssh-agents-plugin is not set up to handle 
>> PowerShell as the default shell. I looked into it a while back but didn't 
>> make good progress.
>>
>> On Tue, Feb 9, 2021 at 2:45 AM Amedee Van Gasse  
>> wrote:
>>
>>> FYI PowerShell is the default SSH shell on this machine.
>>>
>>> On Tuesday, February 9, 2021 at 10:27:38 AM UTC+1 Amedee Van Gasse wrote:
>>>
 I got this when connecting to a Windows node, how do I fix this?

 [02/09/21 10:20:58] [SSH] SSH host key matches key seen previously for 
 this host. Connection will be allowed.
 [02/09/21 10:20:58] [SSH] Authentication successful.
 [02/09/21 10:20:59] [SSH] The remote user's environment is:
 Set-Variable : Cannot process command because of one or more missing 
 mandatory parameters: Name.
 At line:1 char:1
 + set
 + ~~~
 + CategoryInfo  : InvalidArgument: (:) [Set-Variable], 
 ParameterBindingException
 + FullyQualifiedErrorId : 
 MissingMandatoryParameter,Microsoft.PowerShell.Commands.SetVariableCommand
  
 [02/09/21 10:21:00] [SSH] Checking java version of 
 C:\Users\jenkins/jdk/bin/java
 [02/09/21 10:21:01] [SSH] C:\Users\jenkins/jdk/bin/java -version 
 returned 11.0.10.
 [02/09/21 10:21:01] [SSH] Starting sftp client.
 [02/09/21 10:21:01] [SSH] Copying latest remoting.jar...
 [02/09/21 10:21:02] [SSH] Copied 1,521,553 bytes.
 Expanded the channel window size to 4MB
 [02/09/21 10:21:02] [SSH] Starting agent process: cd "C:\Users\jenkins" 
 && C:\Users\jenkins/jdk/bin/java  -jar remoting.jar -workDir 
 C:\Users\jenkins -jar-cache C:\Users\jenkins/remoting/jarCache
 At line:1 char:23
 + cd "C:\Users\jenkins" && C:\Users\jenkins/jdk/bin/java  -jar remoting 
 ...
 +   ~~
 The token '&&' is not a valid statement separator in this version.
 + CategoryInfo  : ParserError: (:) [], 
 ParentContainsErrorRecordException
 + FullyQualifiedErrorId : InvalidEndOfLine
  
 Agent JVM has terminated. Exit code=1
 [02/09/21 10:21:02] Launch failed - cleaning up connection
 [02/09/21 10:21:02] [SSH] Connection closed.
 SSHLauncher{host='ec2-3-123-229-137.eu-central-1.compute.amazonaws.com', 
 port=22, credentialsId='b56e65e1-beb0-4ad3-bcaa-e9c7aea3c4f8', 
 jvmOptions='', javaPath='', prefixStartSlaveCmd='', 
 suffixStartSlaveCmd='', 
 launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, 
 sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.ManuallyTrustedKeyVerificationStrategy,
  
 tcpNoDelay=true, trackCredentials=true}
 [02/09/21 10:21:02] [SSH] Opening SSH connection to 
 ec2-3-123-229-137.eu-central-1.compute.amazonaws.com:22.
 [02/09/21 10:21:03] [SSH] SSH host key matches key seen previously for 
 this host. Connection will be allowed.
 [02/09/21 10:21:03] [SSH] Authentication successful.
 [02/09/21 10:21:03] [SSH] The remote user's environment is:
 Set-Variable : Cannot process command because of one or more missing 
 mandatory parameters: Name.
 At line:1 char:1
 + set
 + ~~~
 + CategoryInfo  : InvalidArgument: (:) [Set-Variable], 
 ParameterBindingException
 + FullyQualifiedErrorId : 
 MissingMandatoryParameter,Microsoft.PowerShell.Commands.SetVariableCommand
  
 [02/09/21 10:21:04] [SSH] Checking java version of 
 C:\Users\jenkins/jdk/bin/java
 [02/09/21 10:21:04] [SSH] C:\Users\jenkins/jdk/bin/java -version 
 returned 11.0.10.
 [02/09/21 10:21:04] [SSH] Starting sftp client.
 [02/09/21 10:21:04] [SSH] Copying latest remoting.jar...
 Source agent hash is D866F0B482DB94F38E49B26B465D5DB5. Installed agent 
 hash is D866F0B482DB94F38E49B26B465D5DB5
 Verified agent jar. No update is necessary.
 Expanded the channel window size to 4MB
 [02/09/21 10:21:09] [SSH] 

java.lang.NoClassDefFoundError: Could not initialize class com.sun.proxy.$Proxy9

2021-02-11 Thread Amedee Van Gasse
Jenkins version: 2.263.3
Jenkins master: Linux
Jenkins node: Windows Server 2019
Job: multibranch pipeline with Maven build steps

Build fails with

hudson.remoting.Channel$CallSiteStackTrace: Remote call to 
aws-windows-eu-central-1
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1800)
at 
hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
at hudson.remoting.Channel.call(Channel.java:1001)
at hudson.FilePath.act(FilePath.java:1157)
at hudson.FilePath.act(FilePath.java:1146)
at org.jenkinsci.plugins.gitclient.Git.getClient(Git.java:121)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:907)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:838)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1291)
at 
org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
at 
org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
at 
org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
at 
org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
java.lang.NoClassDefFoundError: Could not initialize class 
com.sun.proxy.$Proxy9
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method)
at 
jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at 
jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1022)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1008)
at 
hudson.remoting.RemoteInvocationHandler.wrap(RemoteInvocationHandler.java:169)
at hudson.remoting.Channel.export(Channel.java:813)
at hudson.remoting.Channel.export(Channel.java:776)
at 
org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.writeReplace(LegacyCompatibleGitAPIImpl.java:204)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:566)
at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:1235)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1137)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349)
at hudson.remoting.UserRequest._serialize(UserRequest.java:263)
at hudson.remoting.UserRequest.serialize(UserRequest.java:272)
at hudson.remoting.UserRequest.perform(UserRequest.java:222)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:375)
at 
hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:73)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834)
Caused: java.io.IOException: Remote call on aws-windows-eu-central-1 failed
at hudson.remoting.Channel.call(Channel.java:1007)
at hudson.FilePath.act(FilePath.java:1157)
at hudson.FilePath.act(FilePath.java:1146)
at org.jenkinsci.plugins.gitclient.Git.getClient(Git.java:121)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:907)
at hudson.plugins.git.GitSCM.createClient(GitSCM.java:838)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1291)
at 
org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
at 
org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
at 
org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
at 
org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)



And in the node log:

SEVERE: Failed to load Jenkins.class
java.lang.NoClassDefFoundError: Could not initialize class 
com.thoughtworks.xstream.core.util.CompositeClassLoader
at