1+ pipeline {
2+ agent { label 'master' }
3+ environment {
4+ ML_IMAGE_FOLDER = 'imagefiles'
5+ IMAGE_NAME = 'mlmodelimage'
6+ MODEL_NAME = 'diabetes_regression_model.pkl'
7+ MODEL_VERSION = '1'
8+ SCORE_SCRIPT = 'scoring/score.py'
9+ RESOURCE_GROUP = "${RESOURCE_GROUP}"
10+ WORKSPACE_NAME = "${WORKSPACE_NAME}"
11+ ML_CONTAINER_REGISTRY = "${ML_CONTAINER_REGISTRY}"
12+ }
13+ stages {
14+ stage('initialize') {
15+ steps {
16+ echo 'Remove the previous one!'
17+ }
18+ post {
19+ always {
20+ deleteDir() /* clean up our workspace */
21+ }
22+ }
23+ }
24+ stage('generate_dockerfile') {
25+ steps {
26+ echo "Hello build ${env.BUILD_ID}"
27+ /*checkout scm*/
28+ checkout([$class: 'GitSCM', branches: [[name: '*/ml_model_uc76']],
29+ userRemoteConfigs: [[url: 'https://github.com/Merlion-Crew/MLOpsPython.git/']]])
30+
31+ azureCLI commands: [[exportVariablesString: '/id|SUBSCRIPTION_ID', script: "az account show"]], principalCredentialId: "${AZURE_SP}"
32+
33+ sh '''#!/bin/bash -ex
34+ source /home/azureuser/anaconda3/bin/activate mlopspython_ci
35+ python3 -m ml_service.util.create_scoring_image
36+ '''
37+ }
38+ }
39+ stage('build_and_push') {
40+ steps {
41+ echo "Build docker images"
42+
43+ sh '''#!/bin/bash -ex
44+ az acr login --name $ML_CONTAINER_REGISTRY
45+ docker build -t $NEXUS_DOCKER_REGISTRY_URL/$IMAGE_NAME:$BUILD_ID ./diabetes_regression/scoring/$ML_IMAGE_FOLDER/
46+ '''
47+
48+ withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'nexus-docker-repo',
49+ usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
50+
51+ sh '''#!/bin/bash -ex
52+ docker login -u $USERNAME --password $PASSWORD https://$NEXUS_DOCKER_REGISTRY_URL
53+ docker push $NEXUS_DOCKER_REGISTRY_URL/$IMAGE_NAME:$BUILD_ID
54+ '''
55+ }
56+ }
57+ }
58+ }
59+ }
0 commit comments