diff --git a/Jenkinsfile b/Jenkinsfile index de189b9..18ff1a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,19 +22,31 @@ pipeline { sh "docker build -t registry.proxyq.co/jenkins/website:${env.BUILD_ID} ." } } - stage('Test') { + stage('Testing') { steps { echo "start Testing" sh 'sleep 5' echo "finish Testing" } } - stage('Deploy') { + stage('Publish') { steps { - echo "${env.ENV_REGISTRY_URL}" - sh "docker login https://registry.proxyq.co -u ${REGISTRY_CREDENTIALS_USR} -p ${REGISTRY_CREDENTIALS_PSW}" + sh "docker login https://registry.proxyq.co --user ${REGISTRY_CREDENTIALS_USR} --password-stdin ${REGISTRY_CREDENTIALS_PSW}" sh "docker push registry.proxyq.co/jenkins/website:${env.BUILD_ID}" } } + stage('Redeploy') { + steps { + script { + def json = """ + {"username": "test", "password": "test"} + """ + def jwtResponse = httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', validResponseCodes: '200', httpMode: 'POST', ignoreSslErrors: true, consoleLogResponseBody: true, requestBody: json, url: "https://portainer..com/api/auth" + def jwtObject = new groovy.json.JsonSlurper().parseText(jwtResponse.getContent()) + env.JWTTOKEN = "Bearer ${jwtObject.jwt}" + } + echo "${env.JWTTOKEN}" + } + } } }