jenkinsfile 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!groovy
  2. def GetLog(build_url) {
  3. def logurl = build_url + 'consoleText'
  4. def strip = logurl.replaceAll('http://','')
  5. withCredentials([string(credentialsId: 'JenkinsAPI', variable: 'token')]){
  6. responce = httpRequest(contentType: 'APPLICATION_JSON',
  7. httpMode: 'GET',
  8. url: 'http://admin:' + token +'@' + strip)
  9. return strip
  10. }
  11. }
  12. pipeline {
  13. agent {
  14. label 'master'
  15. }
  16. stages {
  17. stage("build project") {
  18. steps {
  19. echo 'go build main.go webPage.go'
  20. }
  21. }
  22. stage("deploy docker") {
  23. steps{
  24. echo 'docker-compose stop schedule'
  25. echo 'docker-compose up --build -d'
  26. }
  27. }
  28. }
  29. post {
  30. success {
  31. echo 'I succeeeded!'
  32. echo GetLog("${BUILD_URL}")
  33. }
  34. unstable {
  35. echo 'I am unstable :/'
  36. }
  37. failure {
  38. echo 'I failed :((('
  39. echo GetLog("${BUILD_URL}")
  40. }
  41. changed {
  42. echo 'things were different before...'
  43. }
  44. }
  45. }