You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/12/25 05:10:07 UTC

[GitHub] lanking520 commented on a change in pull request #13450: [MXNET-862] Basic maven jenkins pipeline

lanking520 commented on a change in pull request #13450: [MXNET-862] Basic maven jenkins pipeline
URL: https://github.com/apache/incubator-mxnet/pull/13450#discussion_r243875330
 
 

 ##########
 File path: scala-package/dev/buildkey.py
 ##########
 @@ -0,0 +1,151 @@
+#!/usr/bin/env python3
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import os
+import json
+import logging
+import subprocess
+
+HOME = os.environ['HOME']
+KEY_PATH = os.path.join(HOME, ".m2")
+
+
+'''
+This file would do the following items:
+    Import keys from AWS Credential services
+    Create settings.xml in .m2 with pass phrase
+    Create security-settings.xml in .m2 with master password
+    Import keys.asc the encrypted keys in gpg
+'''
+
+
+def getCredentials():
+    import boto3
+    import botocore
+    endpoint_url = os.environ['MAVEN_PUBLISH_SECRET_ENDPOINT_URL']
+    secret_creds_name = os.environ['MAVEN_PUBLISH_SECRET_NAME_CREDENTIALS']
+    secret_key_name = os.environ['MAVEN_PUBLISH_SECRET_NAME_GPG']
+    region_name = os.environ['DOCKERHUB_SECRET_ENDPOINT_REGION']
+
+    session = boto3.Session()
+    client = session.client(
+        service_name='secretsmanager',
+        region_name=region_name,
+        endpoint_url=endpoint_url
+    )
+    try:
+        get_secret_value_response = client.get_secret_value(
+            SecretId=secret_creds_name
+        )
+        get_secret_key_response = client.get_secret_value(
+            SecretId=secret_key_name
+        )
+    except botocore.exceptions.ClientError as client_error:
+        if client_error.response['Error']['Code'] == 'ResourceNotFoundException':
+            name = (secret_key_name if get_secret_value_response
+                    else secret_creds_name)
+            logging.exception("The requested secret %s was not found", name)
+        elif client_error.response['Error']['Code'] == 'InvalidRequestException':
+            logging.exception("The request was invalid due to:")
+        elif client_error.response['Error']['Code'] == 'InvalidParameterException':
+            logging.exception("The request had invalid params:")
+        else:
+            raise
+    else:
+        secret = get_secret_value_response['SecretString']
+        secret_dict = json.loads(secret)
+        secret_key = get_secret_key_response['SecretString']
+        return secret_dict, secret_key
+
+
+def importASC(key, gpgPassphrase):
+    filename = os.path.join(KEY_PATH, "key.asc")
+    with open(filename, 'w') as f:
+        f.write(key)
+    subprocess.run(['gpg2', '--batch', '--yes',
+                    '--passphrase=\"{}\"'.format(gpgPassphrase),
+                    "--import", "{}".format(filename)])
+
+
+def encryptMasterPSW(password):
+    result = subprocess.run(['mvn', '--encrypt-master-password', password],
+                            stdout=subprocess.PIPE)
+    return str(result.stdout)[2:-3]
+
+
+def encryptPSW(password):
+    result = subprocess.run(['mvn', '--encrypt-password', password],
+                            stdout=subprocess.PIPE)
+    return str(result.stdout)[2:-3]
+
+
+def masterPSW(password):
+    with open(os.path.join(KEY_PATH, "settings-security.xml"), "w") as f:
+        f.write("<settingsSecurity>\n <master>{}</master>\n</settingsSecurity>"
+                .format(password))
+
+
+def severPSW(username, password, gpgPassphrase):
 
 Review comment:
   The Apache server

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services