jenkinsfile 1.0 KB

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