Re: Pipeline: Is SCM revision information stored with each build?

2017-08-16 Thread Dallas Clement
Answering my own question again.  It looks like there is some API available 
for getting SCM revision info in a groovy sandbox environment. 

def getChanges() {
  def lines = []
  def changeSets = currentBuild.changeSets
  for (int i = 0; i < changeSets.size(); i++) {
def entries = changeSets[i].items
for (int j = 0; j < entries.length; j++) {
  def entry = entries[j]
  lines.add("${entry.commitId} by ${entry.author} on ${new 
Date(entry.timestamp)}: ${entry.msg}")
  def files = new ArrayList(entry.affectedFiles)
  for (int k = 0; k < files.size(); k++) {
def file = files[k]
lines.add("\t${file.editType.name} ${file.path}")
  }
}
  }
  def string = ''
  for (i = 0; i < lines.size(); i++) {
string += lines[i] + '\n'
  }
  return string
}

Trying to get this info from currentBuild.rawBuild seems nearly impossible 
due to sandbox / security restrictions.

On Wednesday, August 16, 2017 at 12:46:46 PM UTC-5, Dallas Clement wrote:
>
> I know that I can get the latest revision for the current build by 
> executing a shell command such as:
>   def currentCommit = sh(returnStdout: true, script: 'git rev-parse 
> HEAD').trim()
>
> But I would like to get the commit hash associated with a previous build. 
>  The reason I want to do this is so that I can list all commits associated 
> with a given build since the previous build.
>

-- 
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/cd74bcbf-0f94-4b36-a180-4489f74bd01c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: java.io.IOException: Unable to read /var/lib/jenkins/jobs/MyJobTest/config.xml

2017-08-16 Thread Thad Guidry
Yes we do.  Versions are the latest on new Jenkins and latest or near 
latest (1 version back) on the old Jenkins.

Unfortunately, the logs are not clear on if a particular plugin was causing 
an issue... it treats the whole flow-definition as an exception.
I would expect much better handling of those kinds of errors by Jenkins.

-Thad

-- 
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/f276d19c-7318-49a9-8b1b-b765765d3df4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: java.io.IOException: Unable to read /var/lib/jenkins/jobs/MyJobTest/config.xml

2017-08-16 Thread Slide
Do you have all the same plugins (and plugin versions) installed on the
second instance of Jenkins?

On Wed, Aug 16, 2017 at 12:44 PM Thad Guidry  wrote:

> We recently backed up our /jobs folder on Jenkins 2.73 and copied this to
> another Jenkins.2.73 server running on RHEL 7.1
>
> We get the following stacktrace on many of them trying to read the
> config.xml and not all the jobs are being loaded onto the Job dashboard...
>
> Aug 16, 2017 2:01:32 PM jenkins.InitReactorRunner$1 onTaskFailed
> SEVERE: Failed Loading item MyJobTest
> java.io.IOException: Unable to read
> /var/lib/jenkins/jobs/MyJobTest/config.xml
> at hudson.XmlFile.read(XmlFile.java:151)
> at hudson.model.Items.load(Items.java:371)
> at jenkins.model.Jenkins$17.run(Jenkins.java:3116)
> at
> org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
> at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
> at jenkins.model.Jenkins$7.runTask(Jenkins.java:1090)
> at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
> at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
> 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)
> Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException:
> flow-definition
> at
> com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> hudson.util.XStream2$CompatibilityMapper.realClass(XStream2.java:285)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> hudson.util.xstream.MapperDelegate.realClass(MapperDelegate.java:43)
> at
> com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> at
> com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:48)
> at
> com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
> at
> com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:133)
> at
> com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
> at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1189)
> at hudson.util.XStream2.unmarshal(XStream2.java:114)
> at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1173)
> at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1053)
> at hudson.XmlFile.read(XmlFile.java:149)
> ... 10 more
>
> --
> You received this message because 

java.io.IOException: Unable to read /var/lib/jenkins/jobs/MyJobTest/config.xml

2017-08-16 Thread Thad Guidry
We recently backed up our /jobs folder on Jenkins 2.73 and copied this to 
another Jenkins.2.73 server running on RHEL 7.1

We get the following stacktrace on many of them trying to read the 
config.xml and not all the jobs are being loaded onto the Job dashboard...

Aug 16, 2017 2:01:32 PM jenkins.InitReactorRunner$1 onTaskFailed
SEVERE: Failed Loading item MyJobTest
java.io.IOException: Unable to read 
/var/lib/jenkins/jobs/MyJobTest/config.xml
at hudson.XmlFile.read(XmlFile.java:151)
at hudson.model.Items.load(Items.java:371)
at jenkins.model.Jenkins$17.run(Jenkins.java:3116)
at 
org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
at jenkins.model.Jenkins$7.runTask(Jenkins.java:1090)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
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)
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: 
flow-definition
at 
com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
hudson.util.XStream2$CompatibilityMapper.realClass(XStream2.java:285)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
hudson.util.xstream.MapperDelegate.realClass(MapperDelegate.java:43)
at 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at 
com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:48)
at 
com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at 
com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:133)
at 
com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1189)
at hudson.util.XStream2.unmarshal(XStream2.java:114)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1173)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1053)
at hudson.XmlFile.read(XmlFile.java:149)
... 10 more

-- 
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 

Re: jenkins pipeline post actions not working

2017-08-16 Thread red 888
So if I look at it from old jenkins view I can actually see it under the 
"Stage View" as "Declarative: Post Actions". But how do I view the 
Declarative: Post Actions in Blue Ocean?

On Wednesday, August 16, 2017 at 1:54:27 PM UTC-4, red 888 wrote:
>
> I setup a post action like in the examples:
>
>
> pipeline {
> agent any
> stages {
> stage('Example1') {
> steps {
> bat 'return 1'
> }
> stage('Example2') {
> steps {
> echo 'Wont see this'
> }
> }
> }
> post { 
> always { 
> echo 'I will always say Hello'
> }
> }
> }
>
>
> So I do something in the first stage to make it fail. And I have a post 
> action that always runs, but what happens when I run my pipeline in 
> blueocean is it fails at the first stage and then just stops. Where do I 
> see the post action that is always supposed to run??
>

-- 
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/0d9c5d75-cfd2-4173-93f9-e15ba5463e75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


jenkins pipeline post actions not working

2017-08-16 Thread red 888


I setup a post action like in the examples:


pipeline {
agent any
stages {
stage('Example1') {
steps {
bat 'return 1'
}
stage('Example2') {
steps {
echo 'Wont see this'
}
}
}
post { 
always { 
echo 'I will always say Hello'
}
}
}


So I do something in the first stage to make it fail. And I have a post 
action that always runs, but what happens when I run my pipeline in 
blueocean is it fails at the first stage and then just stops. Where do I 
see the post action that is always supposed to run??

-- 
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/588af3d5-1d9b-4bde-a8fe-e922f944%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pipeline: Is SCM revision information stored with each build?

2017-08-16 Thread Dallas Clement
I know that I can get the latest revision for the current build by 
executing a shell command such as:
  def currentCommit = sh(returnStdout: true, script: 'git rev-parse 
HEAD').trim()

But I would like to get the commit hash associated with a previous build. 
 The reason I want to do this is so that I can list all commits associated 
with a given build since the previous build.

-- 
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/30fc932b-a187-426a-b9bd-fa3c8a19b452%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What is the difference between step vs steps in jenkinsfile?

2017-08-16 Thread red 888


I'm trying to run xunit and I keep seeing examples with only "step" like 
this:


step([$class : 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: 
'', unstableNewThreshold: '', unstableThreshold: '0'],
[$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: 
'', unstableNewThreshold: '', unstableThreshold: '']
 ],
tools : [[$class: 'MSTestJunitHudsonTestType', deleteOutputFiles: true, 
failIfNotNew: false, pattern: "TestResults\\*.trx", skipNoTestFiles: false, 
stopProcessingIfError: true]]])


But I want to run multiple "steps" inside a stage. I don't understand step 
vs steps.


For example this isn't working:

stage('Test') {
steps {
bat "\"${tool 'VSTestRunner'}\" 
%WORKSPACE%\\MyApp\\bin\\Debug\\MyAppTest.dll /logger:trx",
step([$class : 'XUnitPublisher',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '', 
failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '0'],
[$class: 'SkippedThreshold', failureNewThreshold: '', 
failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']
],
tools : [[$class: 'MSTestJunitHudsonTestType',
deleteOutputFiles: true,
failIfNotNew: false,
pattern: "TestResults\\*.trx",
skipNoTestFiles: false,
stopProcessingIfError: true
]]
])
}}

-- 
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/816d8b86-f2f2-470b-b95f-eb2c807d6d1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is is possible to define methods in a declarative pipeline?

2017-08-16 Thread Dallas Clement
I'm answering my own question here.  It looks like this is indeed possible. 
 I added some method definitions at the end of my Jenkinsfile following the 
pipeline definition.  I was able to call the methods from a script {} 
embedded in stages and post sections.

On Wednesday, August 16, 2017 at 11:19:40 AM UTC-5, Dallas Clement wrote:
>
> I would like to be able to define some groovy methods in my declarative 
> Jenkinsfile and call as needed from a script {} section.  For example I 
> would like to define some methods that extract git commit information from 
> the jenkins API and use when notifying concerning build status from one of 
> the pipeline post conditions.  Is it possible to define methods in a 
> declarative pipeline? 
>

-- 
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/75dbde18-e546-47a2-84f6-66e75ef3d991%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Secrets as "environment variables" in containerTemplate of jenkins-kubernetes-plugin

2017-08-16 Thread YAN-HONG WANG
@Carlos, thanks very much.

Am Mittwoch, 16. August 2017 16:59:53 UTC+2 schrieb Carlos Sanchez:
>
> will be in 0.13
>
> On Wed, Aug 16, 2017 at 2:54 PM, YAN-HONG WANG  > wrote:
>
>> Hello Carlos:
>>
>> Is method "*secretEnvVar*" already in *Kubernetes plugin 0.12*? Or that 
>> will be released in nearly future *0.13*?
>>
>> Because I got the error message like this ...
>>
>> *java.lang.NoSuchMethodError: No such DSL method 'secretEnvVar' found among 
>> steps *
>>
>>
>> Thanks very much.
>>
>> Best regards,
>> Hong
>>
>> Am Donnerstag, 10. August 2017 22:42:22 UTC+2 schrieb YAN-HONG WANG:
>>>
>>> @Carlos, Thanks!!!
>>>
>>>
>>> There is a PR for it 
 https://github.com/jenkinsci/kubernetes-plugin/pull/162


 Hi,
>
> In jenkins-kubernetes-plugin, is there any syntax that support using 
> *Secrets 
> as environment variables* in *containerTemplate*?
>
> I just saw something from here.
>
> https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables
>
> So some syntax like "*secretKeyRef*" could be indicated in 
> *containerTemplate?*
>
> apiVersion: v1kind: Podmetadata:
>   name: secret-env-podspec:
>   containers:
> - name: mycontainer
>   image: redis
>   env:
> - name: SECRET_USERNAME
>   valueFrom:
> secretKeyRef:
>   name: mysecret
>   key: username
> - name: SECRET_PASSWORD
>   valueFrom:
> secretKeyRef:
>   name: mysecret
>   key: password
>   restartPolicy: Never
>
> Thanks.
>
> Best regards,
> Hong
>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "Jenkins Users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/a4be1cee-cfd4-48d8-a97e-fa5c30d95ce6%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

 -- 
 You received this message because you are subscribed to a topic in the 
 Google Groups "Jenkins Users" group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/jenkinsci-users/vAZbO6gCgIY/unsubscribe
 .
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6Mht9PHnX7WNFMranPz-J6VvPaQkrx8ci_pDBQ1dGQXcA%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-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/ff873744-f9c1-46df-a32d-6cbd36b2966f%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/769bee99-cd62-4cd2-90d0-2d4379edd31b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative pipeline with loop and input timeout

2017-08-16 Thread Guy Knights
Thanks Victor, I'll take a look at it when I get a chance and see if I can
use your solution.

Cheers,
Guy

On Tue, Aug 15, 2017 at 1:49 PM, Victor Martinez <
victormartinezru...@gmail.com> wrote:

> I did a kind of similar but not equally implementation. The important bit
> is to try/catch and ensure the last true/false command is in the right
> logic, please read the below:
>
> My use case was to run a certain Integration Test, then if it failed for
> whatever reason, prompt to the user whether to rerun them again with a
> certain timeout to avoid infinite waits.
>
> stage('TestCase') {
>   steps {
> script {
>   def filter = 'all'
>   waitUntil {
> def bRun = build job: 'jobX', propagate: false  // To avoid
> failfast/propagate errors
> if 
> (bRun.getRawBuild().result.isWorseOrEqualTo(hudson.model.Result.FAILURE))
> {
>   def userInput = true
>   def didTimeout = false
>   def inputValue
>   try {
> // Timeout in case to avoid running this forever
> timeout(time: 60, unit: 'SECONDS') {
>   inputValue = input(
>   id: 'userInput', message: 'jobX failed let\'s rerun
> it?', parameters: [
> [$class: 'BooleanParameterDefinition', defaultValue:
> true, description: '', name: 'Please confirm you agree with this']
>   ])
> }
>   } catch(err) { // timeout reached or input false
> echo err.toString()
> def user = err.getCauses()[0].getUser()
> if('SYSTEM' == user.toString()) { // SYSTEM means timeout.
>   didTimeout = true
> } else {
>   userInput = false
>   echo "Aborted by: [${user}]"
> }
>   }
>   if (didTimeout) {
> echo "no input was received before timeout"
> false // false will cause infinite loops but it's a way to
> keep retrying, otherwise use true and will exit the loop
>   } else if (userInput == true) {
> echo "this was successful"
> false // if user answered then iterate through the loop
> again
>   } else {
> echo "this was not successful"
> currentBuild.result = 'ABORTED'
> true  // if user aborted the input then exit the loop
>   }
> } else {
>   currentBuild.result = 'SUCCESS'
>   true  // if build finished successfully as expected then
> exit the loop
> }
>   }
> }
>   }
> }
>
> The above snippet was based on the below how-to:
> - https://support.cloudbees.com/hc/en-us/articles/
> 226554067-Pipeline-How-to-add-an-input-step-with-timeout-
> that-continues-if-timeout-is-reached-using-a-default-value
>
> I hope it helps
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/jenkinsci-users/upVzT3SOZy8/unsubscribe.
> To unsubscribe from this group and all its topics, 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/dc49bafb-5772-4f03-9ff3-81bb465a8953%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/CANNH9mvPMt4dB5aMuhiDJdZ3vHsiADiiSdS_L%2BfxeDym8h2rbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Is is possible to define methods in a declarative pipeline?

2017-08-16 Thread Dallas Clement
I would like to be able to define some groovy methods in my declarative 
Jenkinsfile and call as needed from a script {} section.  For example I 
would like to define some methods that extract git commit information from 
the jenkins API and use when notifying concerning build status from one of 
the pipeline post conditions.  Is it possible to define methods in a 
declarative pipeline? 

-- 
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/db56ff5f-608f-4e13-97dc-dfb446fff907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Dallas Clement
Thanks for these helpful ideas.  Seems like this would work fine.   One 
last related question:  How dost one trigger the 'unstable' condition in 
the pipeline post section?

On Wednesday, August 16, 2017 at 11:09:12 AM UTC-5, slide wrote:
>
> You could do this with a map
>
> Map stageResults = [:]
>
> stage('Foo') {
> stageResults['Foo'] = Result.FAILURE
> }
>
> stage('Bar') {
>stageResults['Bar'] = Result.SUCCESS
> }
>
> Not ideal, but should work.
>
> On Wed, Aug 16, 2017 at 8:57 AM Victor Martinez  > wrote:
>
>> Unfortunately, I'm also asking a kind of similar question:
>> - https://groups.google.com/forum/#!topic/jenkinsci-users/9UYN8FZL35k
>>
>> I haven't worked out how to do it without creating variables specifically 
>> per stage
>>
>> -- 
>> 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/ce3fbe5c-df26-471c-a804-1d6643650b9b%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/0a47ebd1-1fbb-4844-891b-6dd797138787%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Slide
You could do this with a map

Map stageResults = [:]

stage('Foo') {
stageResults['Foo'] = Result.FAILURE
}

stage('Bar') {
   stageResults['Bar'] = Result.SUCCESS
}

Not ideal, but should work.

On Wed, Aug 16, 2017 at 8:57 AM Victor Martinez <
victormartinezru...@gmail.com> wrote:

> Unfortunately, I'm also asking a kind of similar question:
> - https://groups.google.com/forum/#!topic/jenkinsci-users/9UYN8FZL35k
>
> I haven't worked out how to do it without creating variables specifically
> per stage
>
> --
> 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/ce3fbe5c-df26-471c-a804-1d6643650b9b%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/CAPiUgVegHJdGw3qpNW3QgOcAoLBqpS42ZhxbN9SmaP5Xu7Qk-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Victor Martinez
Unfortunately, I'm also asking a kind of similar question:
- https://groups.google.com/forum/#!topic/jenkinsci-users/9UYN8FZL35k

I haven't worked out how to do it without creating variables specifically 
per stage

-- 
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/ce3fbe5c-df26-471c-a804-1d6643650b9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Dallas Clement
Victor, you are sure right.  This works like a champ!  Thank you very much. 
 Do you know if it's possible to get the status for each stage in a 
pipeline?

On Wednesday, August 16, 2017 at 10:13:46 AM UTC-5, Victor Martinez wrote:
>
> As far as I see "currentBuild.getCurrentResult()" is not null even though 
> when no set was explicitly set, this is my snippet and console output
>
> pipeline {
> agent any
> stages {
> stage ('release') {
> steps {
> script {
> echo "echo currentbuild ${BUILD_ID}"
> //sh 'exit 1'
> }
> }
> }
> }
> post {
> changed {
> script {
> echo "${currentBuild.getCurrentResult()}"
> if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
> echo "Previous build failed 
> ${currentBuild?.getPreviousBuild()?.number} and now it has been fixed"
> }
> }
> }
> }
> }
>
> [Pipeline] nodeRunning on master in 
> /var/jenkins_home/workspace/_scratch/test_def[Pipeline] {[Pipeline] 
> stage[Pipeline] { (release)[Pipeline] script[Pipeline] {[Pipeline] echoecho 
> currentbuild 37[Pipeline] }[Pipeline] // script[Pipeline] }[Pipeline] // 
> stage[Pipeline] stage[Pipeline] { (Declarative: Post Actions)[Pipeline] 
> script[Pipeline] {[Pipeline] echoSUCCESS[Pipeline] echoPrevious build failed 
> 36 and now it has been fixed[Pipeline] }[Pipeline] // script[Pipeline] 
> }[Pipeline] // stage[Pipeline] }[Pipeline] // node[Pipeline] End of 
> PipelineFinished: SUCCESS
>
>
> Cheers
>
>

-- 
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/4adbb842-6f3f-4605-9497-15a050a792bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Victor Martinez
As far as I see "currentBuild.getCurrentResult()" is not null even though 
when no set was explicitly set, this is my snippet and console output

pipeline {
agent any
stages {
stage ('release') {
steps {
script {
echo "echo currentbuild ${BUILD_ID}"
//sh 'exit 1'
}
}
}
}
post {
changed {
script {
echo "${currentBuild.getCurrentResult()}"
if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Previous build failed 
${currentBuild?.getPreviousBuild()?.number} and now it has been fixed"
}
}
}
}
}

[Pipeline] nodeRunning on master in 
/var/jenkins_home/workspace/_scratch/test_def[Pipeline] {[Pipeline] 
stage[Pipeline] { (release)[Pipeline] script[Pipeline] {[Pipeline] echoecho 
currentbuild 37[Pipeline] }[Pipeline] // script[Pipeline] }[Pipeline] // 
stage[Pipeline] stage[Pipeline] { (Declarative: Post Actions)[Pipeline] 
script[Pipeline] {[Pipeline] echoSUCCESS[Pipeline] echoPrevious build failed 36 
and now it has been fixed[Pipeline] }[Pipeline] // script[Pipeline] }[Pipeline] 
// stage[Pipeline] }[Pipeline] // node[Pipeline] End of PipelineFinished: 
SUCCESS


Cheers

-- 
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/94b93b0a-cf6e-4210-a459-a60019560bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative pipeline: "Data generation failure: null" in input step

2017-08-16 Thread Sascha Schwarz
On Wednesday, 16 August 2017 12:36:05 UTC+2, Victor Martinez wrote:
>
> Hey,
>
> It seems you are missing the displayVersion and valueExpression attributes.
>

Thank you! :)

It seems that the displayVersion Parameter must not be null. :/

Thanks again
Sascha

-- 
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/08db8e28-3f0f-49df-8fcf-41b6a7855044%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Image name and version of containerTemplate by variable created during execution of pipeline?

2017-08-16 Thread Carlos Sanchez
On Wed, Aug 16, 2017 at 1:55 PM, YAN-HONG WANG 
wrote:

> Hello Carlos,
>
> Now in my Jenkinsfile.groovy I create a *slave container* in *other pod*.
> I use "*load*" this function to implement.
>
> But, I found out that *pod *will be *destroyed automatically* when that *slave
> container* was executed.
> That slave container is a PostgreSQL daemon. That needs to be held for
> waiting other container binding.
> And then unfortunately that *slave container was destroyed by destroyed
> pod.*
>
> Is there any *syntax *or *podTemplate argument* can avoid pod destroyed
> automatically?
>

You can create multiple containers as part of a pod, then can use them
until podTemplate is closed, when the pod is destroyed


>
> Thanks very much.
>
> Best regards,
> Hong
>
>
> Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
>>
>> Hello Carlos,
>>
>> Thanks for your hint.
>> I will try to create new container in other new pod.
>>
>> Hong
>>
>> Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
>>>
>>> You can not add containers to a pod after the pod is created, that
>>> doesn't work in kubernetes nor docker swarm
>>>
>>> On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG 
>>> wrote:
>>>
 Hello Carlos,

 If I use the container created function like below:

 def dbImage = *docker.image*( "myregistry:5000/imagename:1.0.0.1" )
 def c = *dbImage.run*("--network jenkins-network --name mycontainer")

 But, this container seems will be created *in host* side, *not in*
 Kubernetes side, right?

 So this container even was created ... but it could *not* communicate
 with *other container* ...

 Best regards,
 Hong


 Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
>
> Hello Carlos,
>
> Thanks for correction.
> But, if containerTemplate can't be defined outside of podTemplate.
>
> How could I *create* a container in the *execution of pipeline*?
> And that container can also *stay* in the *same* pod.
> Is there some other *syntax* or some *container creation function*
> could be applied in *node area*?
>
> Thanks very much again.
>
> Best regards,
> Hong
>
> Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
>>
>> you can't define containers outside podTemplate
>>
>> On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG 
>> wrote:
>>
>>> Hello Carlos,
>>>
>>> I tried it already with all *plain hard code*. And insert in the
>>> execution of pipeline.
>>>
>>> Something like this below:
>>>
>>> podTemplate(
>>>
>>>   label: "pod",
>>>
>>>   containers: [
>>> containerTemplate(
>>>   name: "*worker*",
>>>   image: "myregistry:5000/jenkins-worker:latest",
>>>   envVars:[
>>> containerEnvVar( key: "PGUSER", value: "pguser" ),
>>> containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
>>>   ],
>>>   alwaysPullImage: true,
>>>   ttyEnabled: true,
>>>   command: "cat"
>>> )
>>>   ]
>>> )
>>> {
>>> node( "pod" ) {
>>>
>>>   container( "*worker*" ) {
>>>
>>> stage( "DB Tests" ) {
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *  containers: [containerTemplate(  name:
>>> "db",  image: "myregistry:5000/postgresql-server:1.0",
>>> alwaysPullImage: true,  ttyEnabled: true)  ]*
>>>
>>>   container( "*db*" ) {
>>> sh "psql --host=127.0.0.1 --dbname=$project --echo-all
>>> --command='SELECT timestamp FROM info'"
>>>   }
>>> }
>>>   }
>>> }
>>> }
>>>
>>> And I got the error message result below:
>>>
>>> *Waiting for container container [db] of pod [slave-87s57-3zc4x] to 
>>> become ready.*
>>>
>>>
>>> Do I make something wrong in script?
>>> Or that need to be implemented by other form or syntax?
>>>
>>> Thanks very much.
>>>
>>> BR
>>> Hong
>>>
>>> Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

 Have you tried?

 On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG 
 wrote:

> Hello all,
>
> I saw the tutorial with jenkins-kubernetes-plugin.
> https://github.com/jenkinsci/kubernetes-plugin
>
> The examples of containerTemplate are all created in the *beginning
> *of groovy file.
> And the *image name with version number *are *fixed*, too.
> Example like this below.
>
> containerTemplate(
> name: 'maven',
> image: 'maven:3.3.9-jdk-8-alpine',
> ttyEnabled: true,
> command: 'cat'

Re: Using Secrets as "environment variables" in containerTemplate of jenkins-kubernetes-plugin

2017-08-16 Thread Carlos Sanchez
will be in 0.13

On Wed, Aug 16, 2017 at 2:54 PM, YAN-HONG WANG 
wrote:

> Hello Carlos:
>
> Is method "*secretEnvVar*" already in *Kubernetes plugin 0.12*? Or that
> will be released in nearly future *0.13*?
>
> Because I got the error message like this ...
>
> *java.lang.NoSuchMethodError: No such DSL method 'secretEnvVar' found among 
> steps *
>
>
> Thanks very much.
>
> Best regards,
> Hong
>
> Am Donnerstag, 10. August 2017 22:42:22 UTC+2 schrieb YAN-HONG WANG:
>>
>> @Carlos, Thanks!!!
>>
>>
>> There is a PR for it https://github.com/jenkinsci/k
>>> ubernetes-plugin/pull/162
>>>
>>>
>>> Hi,

 In jenkins-kubernetes-plugin, is there any syntax that support using 
 *Secrets
 as environment variables* in *containerTemplate*?

 I just saw something from here.
 https://kubernetes.io/docs/concepts/configuration/secret/#
 using-secrets-as-environment-variables

 So some syntax like "*secretKeyRef*" could be indicated in
 *containerTemplate?*

 apiVersion: v1kind: Podmetadata:
   name: secret-env-podspec:
   containers:
 - name: mycontainer
   image: redis
   env:
 - name: SECRET_USERNAME
   valueFrom:
 secretKeyRef:
   name: mysecret
   key: username
 - name: SECRET_PASSWORD
   valueFrom:
 secretKeyRef:
   name: mysecret
   key: password
   restartPolicy: Never

 Thanks.

 Best regards,
 Hong

 --
 You received this message because you are subscribed to the Google
 Groups "Jenkins Users" group.
 To view this discussion on the web visit https://groups.google.com/d/ms
 gid/jenkinsci-users/a4be1cee-cfd4-48d8-a97e-fa5c30d95ce6%
 40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Jenkins Users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/jenkinsci-users/vAZbO6gCgIY/unsubscribe.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/jenkinsci-users/CALHFn6Mht9PHnX7WNFMranPz-J6VvPaQkrx8ci_
>>> pDBQ1dGQXcA%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/ff873744-f9c1-46df-a32d-6cbd36b2966f%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/CALHFn6MDna-sEzUeE6quz9B6uujK5sNbH_UfUF7A%3DgRpdh0Xfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Dallas Clement
Victor, thanks for the help here.  I have played with the 'changed' action 
and also currentBuild.result and currentBuild?.getPreviousBuild(), but it 
looks like this variable is null unless explicitly set in one of the 
pipeline stages.  What I really want is the status Jenkins uses to 
determine which post condition is applicable, i.e. success, failure, etc. 
 It knows somehow, presumably based on $? values from each step.

On Wednesday, August 16, 2017 at 5:05:27 AM UTC-5, Victor Martinez wrote:
>
> Hey Dallas,
>
> Cannot you just use the changed condition 
> https://jenkins.io/doc/book/pipeline/syntax/#post? Then you can use the 
> http://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html#resultIsBetterOrEqualTo-java.lang.String-
>
> See the below snippet:
>
> ...
> post {
> changed {
> script { 
> // 
> http://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html#resultIsBetterOrEqualTo-java.lang.String-
> if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
> echo "Previous build failed 
> ${currentBuild?.getPreviousBuild()?.number} and now it has been fixed"
> }
> }
> }
> }
> ... 
>
>
> Cheers
>

-- 
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/f7e40755-50c6-4077-9288-a9336476f9aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to restrict access to some shared libraries methods

2017-08-16 Thread R. Tyler Croy
(replies inline)

On Wed, 16 Aug 2017, Cristiano Kliemann wrote:

> Hi,
> 
> We are developing pipeline shared libraries to organize common tasks. Some 
> of the functionality involves deploying files to our binary repository. 
> We've decided to create small classes and methods to keep things simple and 
> maintainable. But we have some concerns about what the developer should 
> have access. Take the example below:


On what basis are you intending to restrict the access? You can simply add
Pipeline Shared Libraries at a Folder level, and only add the referenced Shared
Library to a folder with "trusted" Pipelines.

Or the deploy() method could maybe look at `env.JOB_NAME` to select from an
inclusion list of Pipelines which execute the rest of the method body?

Otherwise, I'm not sure how you might wish to restrict the usage.


Cheers
- 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/20170816143854.xmzlca6xwlrpb5x5%40blackberry.coupleofllamas.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


How to restrict access to some shared libraries methods

2017-08-16 Thread Cristiano Kliemann
Hi,

We are developing pipeline shared libraries to organize common tasks. Some 
of the functionality involves deploying files to our binary repository. 
We've decided to create small classes and methods to keep things simple and 
maintainable. But we have some concerns about what the developer should 
have access. Take the example below:

src/com/mycompany/Deployer.groovy:

package com.mycompany
class Deployer {
  // I don't want the developer to call this method directly
  def deploy(file) {
// 
  }
}

vars/myDeploy.groovy:
def call(file) {
  checkFileContents(file)
  checkPermissions()
  // ... does a lot of things and then:
  new com.mycompany.Deployer().deploy(file)
}

Jenkinsfile:
node() {
  // Ok
  myDeploy('file.bin')

  // Should raise an exception
  new com.mycomany.Deployer().deploy('file.bin')
}

We would like to restrict which methods can be directly called from the 
Jenkinsfile.

Is there any way to implement such restriction?

Thanks,
Cristiano

-- 
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/abe5133d-0edf-44f0-8add-40b14200d6b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Jenkins Pipeline is not getting displayed Properly in BlueOcean

2017-08-16 Thread SS
Hi Devs,

This is my first post to this forum . We had a requirement to create a 
pipeline having the below flow.













For the above flow written the code snippet is below 

*node('Some Node') {*
* try{*
* stage('Start'){*
* currentBuild.result = 'SUCCESS'*
* echo "Begin of Pipeline"*

* }*

* stage('Checkout and Init'){*
* //Step 0*
* parallel (*
* "Checkout Platform" : {*
* dir('platform') {*
* echo "Checkout Platform"*
* }*
*  },*
*  "Checkout Platform Clover":{*
* dir('platformclover') {*
* echo "Checkout Platform Clover"*
* }*
*  },*
*  "Checkout Platform Sonar":{*
* dir('platformsonar') {*
* echo "Checkout Platform Sonar"*
* }*
*  },*
*  "Checkout Automation Framework":{*
*  dir('automationframework') {*
*  echo "Checkout Automation Framework"*
*  }*
* },*
*  "Checkout Automation BVT":{*
* dir('automationbvt') {*
* echo "Checkout Automation BVT"*
* }*
*  },*
*  "Checkout Automation Server":{*
* dir('automationserver') {*
* echo "Checkout Automation Server"*
* }*
*  },*
*  "Checkout Automation Web":{*
* dir('automationweb') {*
* echo "Checkout Automation Web"*
* }*
*  }*

* )*
* //Step 2*
* echo "Load Properties"*

* }*
* stage('Print Change Log'){*
* //Step 0 *
* echo "Print ChangeLog"*

* }*
* stage('Platform_Build') {*
* //Step 1*
*   echo "Build Platform"*
* //Step 2*
* echo "Copy Platform to Common Stage"*

* //Step 3*
* echo "Update Current"*
* }*
* parallel (*
*  "Platform_Clover" : {*
* stage("Platform Clover"){*
* //Step 1*
*   echo "Build Platform Clover"*
* //Step 2*
* echo "Copy Platform Clover to Common Stage"*

* //Step 3*
* echo "Update Current"*
* }*
* },*

*  "Automation Build and Deploy" : {  *
* stage('Platform_Deploy'){*
* //Step 1 Platform_Deploy*
*  echo "Deploy Platform to Nexus"*
* }*
* stage('Automation_Framework_Build'){*
* //Step 1*
*echo "Build Automation Framework"*

* }*
* parallel (*
* "Build_BVT_Automation" : {*
*   //Step 1*
*  echo "Build Automation BVT"*
  
*   //Step2*
*echo "Build Current Automation BVT"*
* },*
* "Build_Web_Automation" : {*
*  //Step 1*
*  echo "Build Automation Web"*
  
*   //Step2*
*echo "Build Current Automation Web"*
* },*
* "Build_Server_Automation" : {*
*   //Step 1*
*  echo "Build Automation Server"*
  
*   //Step2*
*echo "Build Current Automation Server"*
* }*
* )*
* stage('Deploy_Automation_Code') {*
* //Step 1*
* echo "Deploy Automation Code"*

* }*
* },*

*  "Platform_SonarQube" : {*
* echo "Build Sonarqube"*
* }*
* )*
* stage('End'){*
* echo "Complete Platform Pipeline"*
* }*
* }catch(Exception e){*
* currentBuild.result = 'FAILURE'*
* }*
* finally{ *
* if (currentBuild.result.toString().equals('SUCCESS')){*
* echo "Create GIT Tag" *
* }*
* echo "Send Email Notification"*
* }*
*}*

The above code is giving something crap in BlueOcean and the stage like "
*Deploy_Automation_Code*" is not seen at all in the UI.
The first node is parallel "AUtomation Build and Deploy" step is showing 
the echo of two stages.
Using Jenkins Version 2.46.2.Below is the UI which I am getting in BlueOcean





Can anyone give some expert thoughts where I am missing something and any 
existing defect with already there in BlueOcean. Thanks a ton in Advance

Thanks,
Satbachan

-- 
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/ba1f35be-95d8-43b5-9780-94f58a08c9d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Secrets as "environment variables" in containerTemplate of jenkins-kubernetes-plugin

2017-08-16 Thread YAN-HONG WANG
Hello Carlos:

Is method "*secretEnvVar*" already in *Kubernetes plugin 0.12*? Or that 
will be released in nearly future *0.13*?

Because I got the error message like this ...

*java.lang.NoSuchMethodError: No such DSL method 'secretEnvVar' found among 
steps *


Thanks very much.

Best regards,
Hong

Am Donnerstag, 10. August 2017 22:42:22 UTC+2 schrieb YAN-HONG WANG:
>
> @Carlos, Thanks!!!
>
>
> There is a PR for it 
>> https://github.com/jenkinsci/kubernetes-plugin/pull/162
>>
>>
>> Hi,
>>>
>>> In jenkins-kubernetes-plugin, is there any syntax that support using 
>>> *Secrets 
>>> as environment variables* in *containerTemplate*?
>>>
>>> I just saw something from here.
>>>
>>> https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables
>>>
>>> So some syntax like "*secretKeyRef*" could be indicated in 
>>> *containerTemplate?*
>>>
>>> apiVersion: v1kind: Podmetadata:
>>>   name: secret-env-podspec:
>>>   containers:
>>> - name: mycontainer
>>>   image: redis
>>>   env:
>>> - name: SECRET_USERNAME
>>>   valueFrom:
>>> secretKeyRef:
>>>   name: mysecret
>>>   key: username
>>> - name: SECRET_PASSWORD
>>>   valueFrom:
>>> secretKeyRef:
>>>   name: mysecret
>>>   key: password
>>>   restartPolicy: Never
>>>
>>> Thanks.
>>>
>>> Best regards,
>>> Hong
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Jenkins Users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/a4be1cee-cfd4-48d8-a97e-fa5c30d95ce6%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Jenkins Users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/jenkinsci-users/vAZbO6gCgIY/unsubscribe
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6Mht9PHnX7WNFMranPz-J6VvPaQkrx8ci_pDBQ1dGQXcA%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/ff873744-f9c1-46df-a32d-6cbd36b2966f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Does anyone know if the MSTest plugin supports pipelines and howto use it in a pipeline (jenkinsfile)?

2017-08-16 Thread Daniel Butler
The XUnit plugin has support for MSTest output and is pipeline compatible.
You’d still need to run MSTest from a bat/powershell command but the Xunit 
plugin will publish the test output.


From: jer...@bodycad.com
Sent: 16 August 2017 13:24
To: Jenkins Users
Subject: Re: Does anyone know if the MSTest plugin supports pipelines and howto 
use it in a pipeline (jenkinsfile)?

Sadly no, many puglin are still incompatible, you can see the compatibility 
list here: 
https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md

Since the .trx is just an xml file, you could try to do an .xslt file that do 
the convertion to junit .xml. Maybe someone already did it somewhere, worth 
googling, I known some people have done .trx to .html graph (which you could 
use and publish the html results too).
-- 
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/75edf196-1d55-4bca-b0df-e0025e837f28%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/59943b1b.49bbdf0a.2f877.51b3%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does anyone know if the MSTest plugin supports pipelines and how to use it in a pipeline (jenkinsfile)?

2017-08-16 Thread jerome
Sadly no, many puglin are still incompatible, you can see the compatibility 
list here: 
https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md

Since the .trx is just an xml file, you could try to do an .xslt file that 
do the convertion to junit .xml. Maybe someone already did it somewhere, 
worth googling, I known some people have done .trx to .html graph (which 
you could use and publish the html results too).

-- 
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/75edf196-1d55-4bca-b0df-e0025e837f28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Image name and version of containerTemplate by variable created during execution of pipeline?

2017-08-16 Thread YAN-HONG WANG
Hello Carlos,

Now in my Jenkinsfile.groovy I create a *slave container* in *other pod*.
I use "*load*" this function to implement.

But, I found out that *pod *will be *destroyed automatically* when that *slave 
container* was executed.
That slave container is a PostgreSQL daemon. That needs to be held for 
waiting other container binding.
And then unfortunately that *slave container was destroyed by destroyed 
pod.*

Is there any *syntax *or *podTemplate argument* can avoid pod destroyed 
automatically?

Thanks very much.

Best regards,
Hong

Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
>
> Hello Carlos,
>
> Thanks for your hint.
> I will try to create new container in other new pod.
>
> Hong
>
> Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
>>
>> You can not add containers to a pod after the pod is created, that 
>> doesn't work in kubernetes nor docker swarm
>>
>> On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG  
>> wrote:
>>
>>> Hello Carlos,
>>>
>>> If I use the container created function like below:
>>>
>>> def dbImage = *docker.image*( "myregistry:5000/imagename:1.0.0.1" )
>>> def c = *dbImage.run*("--network jenkins-network --name mycontainer")
>>>
>>> But, this container seems will be created *in host* side, *not in* 
>>> Kubernetes side, right?
>>>
>>> So this container even was created ... but it could *not* communicate 
>>> with *other container* ...
>>>
>>> Best regards,
>>> Hong
>>>
>>>
>>> Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:

 Hello Carlos,

 Thanks for correction.
 But, if containerTemplate can't be defined outside of podTemplate.

 How could I *create* a container in the *execution of pipeline*?
 And that container can also *stay* in the *same* pod.
 Is there some other *syntax* or some *container creation function* 
 could be applied in *node area*?

 Thanks very much again.

 Best regards,
 Hong

 Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
>
> you can't define containers outside podTemplate
>
> On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG  
> wrote:
>
>> Hello Carlos,
>>
>> I tried it already with all *plain hard code*. And insert in the 
>> execution of pipeline.
>>
>> Something like this below:
>>
>> podTemplate(
>>
>>   label: "pod",
>>
>>   containers: [
>> containerTemplate(
>>   name: "*worker*",
>>   image: "myregistry:5000/jenkins-worker:latest",
>>   envVars:[
>> containerEnvVar( key: "PGUSER", value: "pguser" ),
>> containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
>>   ],
>>   alwaysPullImage: true,
>>   ttyEnabled: true,
>>   command: "cat"
>> )
>>   ]
>> )
>> {
>> node( "pod" ) {
>>
>>   container( "*worker*" ) {
>>
>> stage( "DB Tests" ) {
>>
>>
>>
>>
>>
>>
>>
>>
>> *  containers: [containerTemplate(  name: 
>> "db",  image: "myregistry:5000/postgresql-server:1.0",  
>> alwaysPullImage: true,  ttyEnabled: true)  ]*
>>
>>   container( "*db*" ) {
>> sh "psql --host=127.0.0.1 --dbname=$project --echo-all 
>> --command='SELECT timestamp FROM info'"
>>   }
>> }
>>   }
>> }
>> }
>>
>> And I got the error message result below:
>>
>> *Waiting for container container [db] of pod [slave-87s57-3zc4x] to 
>> become ready.*
>>
>>
>> Do I make something wrong in script?
>> Or that need to be implemented by other form or syntax?
>>
>> Thanks very much.
>>
>> BR
>> Hong
>>
>> Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:
>>>
>>> Have you tried?
>>>
>>> On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG  
>>> wrote:
>>>
 Hello all,

 I saw the tutorial with jenkins-kubernetes-plugin.
 https://github.com/jenkinsci/kubernetes-plugin

 The examples of containerTemplate are all created in the *beginning 
 *of groovy file. 
 And the *image name with version number *are *fixed*, too.
 Example like this below.

 containerTemplate(
 name: 'maven',
 image: 'maven:3.3.9-jdk-8-alpine',
 ttyEnabled: true,
 command: 'cat'
 )

 Is that possible or some *syntax *can implement container created 
 during *execution of pipeline*?
 So this container could also run in *the same Pod*.
 Maybe the syntax looks like below.


 //

 ..
 

ERROR: Could not send email as a part of the post-build publishers.

2017-08-16 Thread NIGHIL VADAKKAN



Please help me to resolve this. I am not able to sent failure email 
notification as a part of post build action


Email was triggered for: Failure
Sending email for trigger: Failure
Sending email to: nighi...@microsemi.com
ERROR: Could not send email as a part of the post-build 
publishers.javax.mail.MessagingException 
: 
[EOF]
at 
com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2023) 

at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:1440) 

at 
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:644) 

at javax.mail.Service.connect(Service.java:317) 

at javax.mail.Service.connect(Service.java:176) 

at javax.mail.Service.connect(Service.java:125) 

at javax.mail.Transport.send0(Transport.java:194) 

at javax.mail.Transport.send(Transport.java:124) 

at 
hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:306)
 

at 
hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:284)
 

at 
hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:236)
 

at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) 

at 
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
 

at 
hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:754)
 

at hudson.model.Build$BuildExecution.cleanUp(Build.java:192) 

at hudson.model.Run.execute(Run.java:1649) 

at hudson.model.Run.run(Run.java:1551) 

at 
com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:63) 

at hudson.model.ResourceController.execute(ResourceController.java:88) 

at hudson.model.Executor.run(Executor.java:246) 

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/62cb1eca-225f-4a6c-a8bb-60e4d371b2cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative pipeline: "Data generation failure: null" in input step

2017-08-16 Thread Victor Martinez
Hey,

It seems you are missing the displayVersion and valueExpression attributes.

The below snippet works, 

...

input id: 'userInput',  message: 'Text goes here', parameters:
[[
$class: 'DropdownAutocompleteParameterDefinition',
name: 'MyName',
dataProvider: 
[
$class: 'InlineJsonDataProvider', 
autoCompleteData: '[{"id":"1"},{"id":"2"}]'
],
displayExpression: 'id',
valueExpression: 'id'
]]

...


Cheers

-- 
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/4622bf0b-572c-4f3d-8f3d-2bd666795468%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Victor Martinez
Hey Dallas,

Cannot you just use the changed condition 
https://jenkins.io/doc/book/pipeline/syntax/#post? Then you can use 
the 
http://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html#resultIsBetterOrEqualTo-java.lang.String-

See the below snippet:

...
post {
changed {
script { 

// 
http://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html#resultIsBetterOrEqualTo-java.lang.String-
if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Previous build failed 
${currentBuild?.getPreviousBuild()?.number} and now it has been fixed"
}
}
}
}
... 


Cheers

-- 
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/8f122af7-7a2e-4ab1-8cea-d6bbcc2ae3ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Declarative pipeline: "Data generation failure: null" in input step

2017-08-16 Thread Sascha Schwarz
Hi!
The following Code just produces an empty dropdown list and an error 
message: Data generation failure: null

pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: 
'3'))
}
agent none
stages {
stage('input') {
steps {
input(
id: 'userInput', message: 'Text goes here', parameters: 
[
[ $class: 'DropdownAutocompleteParameterDefinition', 
name: 'MyName', dataprovider: [
[$class: 'InlineJsonDataProvider', 
autoCompleteData: '[{"id":"1"},{"id":"2"}]'
)
   }
}
}
}


How do I use the InlineJsonDataProvider correctly?

Jenkins V 2.60.2
Autocomplete Parameter Plugin V 1.0

Thanks
Sascha

-- 
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/5eaa44dc-020d-4f25-8e91-a57be2ced37d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Release Button or best practice

2017-08-16 Thread Steven Foster
On Tuesday, August 15, 2017 at 6:09:04 PM UTC+1, Simon Richter wrote:
>
>
> You are looking for the "Promoted Builds" plugin. 
>
>
Ah, I did come across this but unfortunately we are using pipeline builds 
and it seems this isn't compatible 

-- 
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/4e285cf7-ba96-40a7-bcd2-d183cd72e472%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Getting the real Jenkins job status for a pipeline job.

2017-08-16 Thread Dallas Clement
I have setup a declarative Jenkinsfile for my project.  I have some post 
conditions defined for success and failure.  I would like to be able to 
determine the job status for the previous build within the 'success' block 
so that  I can know if this success is a recovery from a previous failure. 
 I do understand that the currentBuild.result variable can be set at 
various stages and that the previous build result is available through 
currentBuild.getPreviousBuild()?.getResult().  But this previous build 
result seems to require the setting of currentBuild.result.

At this point, I am more interested in accessing the actual Jenkins job 
status, i.e. whatever it uses to determine whether a job has been a success 
or failure and not rely on currentBuild.result.  Is there some other 
variable available for 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/38b5f9d7-2168-4f93-be78-ff13556c3820%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.