3

How can i access jenkins build status at runtime without email-ext plugin?

i want to access build_status using environment variable of jenkins. Or Any other way to access build status variable of jenkins?

Akhil Jain
  • 13,872
  • 15
  • 57
  • 93
Chikku
  • 61
  • 2
  • 10

2 Answers2

2

The default Jenkins environment variables don't include the build result.

However, you can use the Groovy Postbuild Plugin, which is run under the Jenkins JVM and have access to the current instance of the build.

Then from groovy you can access the build result via manager.build.result. See my answer here for the example usage.

Community
  • 1
  • 1
Vladimir Sinenko
  • 4,629
  • 1
  • 27
  • 39
  • After installing can i get access to build result through ant..? i want the value to be available on ant task i am writing for email triggering? – Chikku Jul 25 '12 at 12:57
  • My Groovy knowledge is about zero, but I think it's possible to set the environment var from Groovy and it'll persist until your Ant task. On my Jenkins server, I store such info in the new workspace file that is processed later by Python script. – Vladimir Sinenko Jul 25 '12 at 16:17
  • Thanks for the reply..one more doubt where can i found location of two dependent job class in jenkins?..inside plugins/somewhere ? i want the location? – Chikku Jul 26 '12 at 05:38
  • I'm sorry, I can't understand what 'two dependent job class' is. You might ask another question, perhaps somebody will help you? – Vladimir Sinenko Jul 26 '12 at 06:26
  • ok..thanks..what i meant is class file created corresponding to two dependent job..i will start it as new thread.. – Chikku Jul 26 '12 at 07:01
1

You can use currentBuild.currentResult which is a global variable inside jenkins server to access the current build status. These variables are accessible inside pipelines.

Further you can check all the available global variables inside the server using below url

http://<server>/pipeline-syntax/globals 
Harsha
  • 505
  • 5
  • 11