jenkinsfile 980 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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(httpMode: 'POST',
  7. url: 'http://admin:' + token +'@' + strip)
  8. return strip
  9. }
  10. }
  11. pipeline {
  12. agent {
  13. label 'master'
  14. }
  15. stages {
  16. stage("build project") {
  17. steps {
  18. echo 'go build main.go webPage.go'
  19. }
  20. }
  21. stage("deploy docker") {
  22. steps{
  23. echo 'docker-compose stop schedule'
  24. echo 'docker-compose up --build -d'
  25. }
  26. }
  27. }
  28. post {
  29. success {
  30. echo 'I succeeeded!'
  31. echo GetLog("${BUILD_URL}")
  32. }
  33. unstable {
  34. echo 'I am unstable :/'
  35. }
  36. failure {
  37. echo 'I failed :((('
  38. echo GetLog("${BUILD_URL}")
  39. }
  40. changed {
  41. echo 'things were different before...'
  42. }
  43. }
  44. }