123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #!groovy
- def GetLog(build_url) {
- def strip = build_url.replaceAll('http://','')
- withCredentials([string(credentialsId: 'JenkinsAPI', variable: 'token')]){
- def creds = 'admin:' + token
- def auth = creds.bytes.encodeBase64().toString()
- responce = httpRequest(httpMode: 'GET',
- url: 'http://' + strip + 'consoleText',
- customHeaders:[[name:'Authorization', value:"Basic ${auth}"]])
- return responce
- }
- }
- pipeline {
- agent {
- label 'master'
- }
- stages {
- stage("build project") {
- steps {
- echo 'go build main.go webPage.go'
- }
- }
- stage("deploy docker") {
- steps{
- echo 'docker-compose stop schedule'
- echo 'docker-compose up --build -d'
- }
- }
- }
- post {
- success {
- echo 'I succeeeded!'
- echo GetLog("${BUILD_URL}")
-
- }
- unstable {
- echo 'I am unstable :/'
- }
- failure {
- echo 'I failed :((('
- echo GetLog("${BUILD_URL}")
- }
- changed {
- echo 'things were different before...'
- }
- }
- }
|