Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Insert the Repository URL of ur API at “Branch Sources” and select your credentials.

...

If you want to have your Jenkinsfile in another repository, select "by Remote Jenkinsfile Provider Plugin" in "Build Configuration" instead of "by Jenkinsfile", then git in "Jenkinsfile SCM" and enter the repository URL of your Jenkinsfile there.

...

Code Block
breakoutModefull-width
pipeline {

    agent any
    
    stages {
    
        stage("is AAGM alive?") {
        
            steps {
				script {
				    echo '------------------------------------------------'
					echo '---------------  is AAGM alive?  ---------------'
					echo '------------------------------------------------'
				
					def response = httpRequest "http://host.docker.internal:8090/api/v1/alive"
					println('Response: '+response.content)
				}
            }
        }
    
        stage("is AAGM ready?") {
        
            steps {
				script {
				    echo '------------------------------------------------'
				    echo '---------------  is AAGM ready?  ---------------'
				    echo '------------------------------------------------'
				
					def response = httpRequest "http://host.docker.internal:8090/api/v1/ready"
					println('Response: '+response.content)
				}
            }
        }
    
        stage("Login and Deploy") {
        
            steps {
				script {
				    echo '------------------------------------------'
				    echo '---------------  Login...  ---------------'
				    echo '------------------------------------------'
				    
				    def bodyLogin = '{"user": "mirco.hoffmann@apiida.com","pass": "myPassword"}'
				    def response = httpRequest contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: "${bodyLogin}" , url: "http://host.docker.internal:8090/api/v1/login?user=mirco.hoffmann@apiida.com&pass=masterkeymasterke"
					println('Response Content: '+response.content)

                    echo '-------------------------------------------'
                    echo '---------------  Deploy...  ---------------'
                    echo '-------------------------------------------'

                    def jsonObj = readJSON text: response.content
                    echo 'Token: '+jsonObj.token 
				
				    def body = '{"source": {"type": "git"},"targets": [{targets}"myTargetNode"],"comment": "Test Migration over API"}'
					
					def migResponse = httpRequest customHeaders:[[name:'X-Token', value:"${jsonObj.token}"]] ,contentType: 'APPLICATION_JSON', httpMode: 'GET', requestBody: "${body}" , url: "http://host.docker.internal:8090/api/v1/apis/{id}myApiId/migrate"
					println('Response: '+migResponse.content)
				}
            }
        }
    }
    
}

In line 53 54 you have to define the targets of the migration.

In line 55 56 you have to insert the id of the API you want to migrate.

...