Build the data transformation application for the Production CentreΒΆ
The Production Centre uses Docker images and deploys them in a Cloud based environment for large scale production campaigns.
This notebook will trigger the build of a Docker image containing the data transformation application.
- A few Python modules to do the job:
In [1]:
import time
import jenkins
import getpass
- Provide the application information required:
In [2]:
app = dict([('artifact_id', 'ewf-satcen-01-02-02'),
('folder', 'satcen'),
('repository', 'Gitlab Groups'),
('community', 'ec-better')])
- Provide your the Jenkins username and API key:
In [3]:
username = raw_input("What is your Jenkins username? ")
api_key = getpass.getpass('And your Jenkins API key:')
- Create two simple functions to submit the build request and to monitor it:
In [4]:
def submit_build_job(server, job, sleep_secs=3):
last_build = server.get_job_info(job)['lastCompletedBuild']['number']
server.build_job(job)
while server.get_job_info(job)['lastBuild']['number'] == last_build:
time.sleep(sleep_secs)
return server.get_job_info(job)['lastBuild']['number']
In [5]:
def monitor_build_job(server, job, sleep_secs=15):
last_build_number = server.get_job_info(job)['lastBuild']['number']
while server.get_build_info(job, last_build_number)['building']:
time.sleep(sleep_secs)
if str(server.get_build_info(job, last_build_number)['result']) == 'SUCCESS':
return True
if str(server.get_build_info(job, last_build_number)['result']) == 'FAILURE':
return False
- Establish a connection with the build component of the Ellip Platform Continuous Integration:
In [6]:
server = jenkins.Jenkins(url='https://build.terradue.com',
username=username,
password=api_key)
- Create the build request path:
In [7]:
job = 'communities/%s/%s/%s/applications/%s/docker' % (app['repository'],
app['community'],
app['folder'],
app['artifact_id'])
In [8]:
print job
communities/Gitlab Groups/ec-better/eth-z/applications/ewf-ethz-01-03-01/docker
- Submit the build job:
In [9]:
submit_build_job(server, job)
Out[9]:
4
- Monitor the build request:
In [ ]:
if monitor_build_job(server, job):
print 'Job build completed'
else:
print 'Job build failed'
At this stage, there is a Docker container with the data transformation ready to be deployed on a Production Centre. This is accomplished in the deploy step.