Commit 1624d75e authored by Guillaume Pasero's avatar Guillaume Pasero

CI: make API token optional

parent 1ecafba8
Pipeline #2012 passed with stage
in 8 minutes and 56 seconds
......@@ -302,16 +302,19 @@ if __name__ == "__main__":
token = sys.argv[4]
refn = sys.argv[5]
else:
if not CheckEnvParameters(['CI_COMMIT_SHA', 'CI_PROJECT_ID', 'CI_PROJECT_DIR', 'K8S_SECRET_API_TOKEN', 'CI_COMMIT_REF_NAME']):
if not CheckEnvParameters(['CI_COMMIT_SHA', 'CI_PROJECT_ID', 'CI_PROJECT_DIR', 'CI_COMMIT_REF_NAME']):
sys.exit(1)
sha1 = os.environ['CI_COMMIT_SHA']
proj = os.environ['CI_PROJECT_ID']
pdir = os.environ['CI_PROJECT_DIR']
token = os.environ['K8S_SECRET_API_TOKEN']
if 'CI_MERGE_REQUEST_REF_PATH' in os.environ.keys():
refn = os.environ['CI_MERGE_REQUEST_REF_PATH']
else:
refn = os.environ['CI_COMMIT_REF_NAME']
if CheckEnvParameters(['K8S_SECRET_API_TOKEN']):
token = os.environ['K8S_SECRET_API_TOKEN']
else:
token = None
handler = Handler()
build_dir = os.path.join( pdir , "build/")
if trace:
......@@ -327,8 +330,9 @@ if __name__ == "__main__":
else:
cdash_url = handler.GetBuildUrl()
( state , error ) = handler.GetLogStatus( os.path.join( pdir , "log") )
if trace:
print ( "cdash_url is: " + cdash_url )
print("CDash build URL : "+cdash_url)
if token is None:
sys.exit(0)
gitlab_url = "https://gitlab.orfeo-toolbox.org/api/v4/projects/"
gitlab_url += proj + "/statuses/" + sha1
params = urllib.parse.urlencode({'name':'cdash:' + handler.site , 'state': state ,\
......
......@@ -65,9 +65,10 @@ if __name__ == "__main__":
# are we in a merge_request pipeline ?
if 'CI_MERGE_REQUEST_IID' in env.keys():
if not CheckEnvParameters(['K8S_SECRET_API_TOKEN']):
print("Make sure you have set a valid acces token for Gitlab API")
print("The K8S_SECRET_API_TOKEN environment variable should be set in 'Settings -> CI/CD -> Variables'")
sys.exit(1)
print("WARNING: Make sure you have set a valid acces token for Gitlab API." \
+ "The K8S_SECRET_API_TOKEN environment variable should be set in 'Settings -> CI/CD -> Variables'" \
+ "Without this token, some feature of the CI platform will be disabled.")
sys.exit(0)
if not CheckEnvParameters(['CI_PROJECT_ID','CI_PIPELINE_ID']):
sys.exit(1)
mrInfo = GitlabRequest('merge_requests/'+env['CI_MERGE_REQUEST_IID'],token=env['K8S_SECRET_API_TOKEN'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment