diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 667b51655dd58000fbecf75e03c608901a9f93a9..d3a0e720ccc64c33f9857fcad0a46daa69c5ec99 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -39,7 +39,7 @@ fast-build:
     - git checkout -f -q $CI_COMMIT_SHA
     - python3 CI/check_twin_pipelines.py
   after_script:
-    - python3 CI/cdash_handler.py $CI_COMMIT_SHA $CI_PROJECT_ID $CI_PROJECT_DIR $K8S_SECRET_CDASH $CI_MERGE_REQUEST_REF_PATH
+    - python3 CI/cdash_handler.py
   script:
     - ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-18.04-fast
     - ccache -s
@@ -56,7 +56,7 @@ fast-build:
     # Checkout the expected branch
     - git checkout -f -q $CI_COMMIT_SHA
   after_script:
-    - python3 CI/cdash_handler.py $CI_COMMIT_SHA $CI_PROJECT_ID $CI_PROJECT_DIR $K8S_SECRET_CDASH $CI_MERGE_REQUEST_REF_PATH
+    - python3 CI/cdash_handler.py
   artifacts:
     when: on_failure
     expire_in: 24 hrs
diff --git a/CI/cdash_handler.py b/CI/cdash_handler.py
index b69587e27f10ec6e82c261a7f70b44ff03dd76d8..aeb1aa9989c23f36d4d5d78baafcc8b34d636f04 100644
--- a/CI/cdash_handler.py
+++ b/CI/cdash_handler.py
@@ -18,6 +18,7 @@
 # limitations under the License.
 #
 
+import os
 import os.path
 import urllib.request
 import urllib.parse
@@ -31,6 +32,16 @@ import time
 
 trace = False
 
+"""
+Check needed environment parameters
+"""
+def CheckEnvParameters(params):
+  for p in params:
+    if not p in os.environ.keys():
+      print("Missing environment variable '"+p+"'")
+      return False
+  return True
+
 class Handler:
 # project
 # site
@@ -239,20 +250,42 @@ site:"+site+", stamp:"+stamp+", name:"+name+", project:"+project+".")
     return ( state , errors)
 
 """
-TODO :
- documentation, header, test if it is possible.
- the script aims only at recovering the build url
-
+  This script aims only at recovering the build url
+  It uses environment variables setup by Gitlab Runner as default:
+    CI_COMMIT_SHA             -> Commit SHA1
+    CI_PROJECT_ID             -> Project ID
+    CI_PROJECT_DIR            -> Project source directory
+    K8S_SECRET_API_TOKEN      -> Token for Gitlab API
+    CI_MERGE_REQUEST_REF_PATH -> Ref name to push the status (only for merge request pipeline)
+    CI_COMMIT_REF_NAME        -> Ref name to push the status
+  They can be overriden by a full command line :
+    cdash_handler.py commit_sha1  project_id  project_directory  token  ref_name
 """
 if __name__ == "__main__":
-  if ( len(sys.argv) < 6 ):
-    print("Usage : "+sys.argv[0]+" commit_sha1 project_id build_directory token ref_name")
-    sys.exit()
+  if ( len(sys.argv) < 6 and len(sys.argv) > 1 ):
+    print("Usage : "+sys.argv[0]+" commit_sha1 project_id project_directory token ref_name")
+    sys.exit(1)
   if trace:
     print (sys.argv)
+  if ( len(sys.argv) >= 6):
+    sha1 = sys.argv[1]
+    proj = sys.argv[2]
+    pdir = sys.argv[3]
+    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']):
+      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']
   handler = Handler()
-  build_dir = os.path.join( sys.argv[3] , "build/")
-  ref_name = sys.argv[5]
+  build_dir = os.path.join( pdir , "build/")
   if trace:
     print("build_dir is: " + build_dir)
   handler.build_dir = build_dir
@@ -269,11 +302,11 @@ if __name__ == "__main__":
   if trace:
     print ( "cdash_url is: " + cdash_url )
   gitlab_url = "https://gitlab.orfeo-toolbox.org/api/v4/projects/"
-  gitlab_url += sys.argv[2] + "/statuses/" + sys.argv[1]
+  gitlab_url += proj + "/statuses/" + sha1
   params = urllib.parse.urlencode({'name':'cdash:' + handler.site , 'state': state ,\
-   'target_url' : cdash_url , 'description' : error , 'ref' : ref_name })
+   'target_url' : cdash_url , 'description' : error , 'ref' : refn })
   gitlab_request = urllib.request.Request(gitlab_url)
-  gitlab_request.add_header('PRIVATE-TOKEN' , sys.argv[4] )
+  gitlab_request.add_header('PRIVATE-TOKEN' , token )
   res = urllib.request.urlopen(gitlab_request, data=params.encode('ascii'))
   if trace:
     print ("gitlab_request.url: " + gitlab_request.full_url)