jenkinsfile 1.1 KB

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