jenkinsfile 887 B

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