Commit 4b5809c7 authored by Guillaume Pasero's avatar Guillaume Pasero

Merge branch 'ci_fix_fast_build' into 'develop'

CI: fix fast build

See merge request orfeotoolbox/otb!504
parents 51e15d69 7312ea7d
Pipeline #1625 passed with stages
in 9 minutes and 54 seconds
......@@ -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
......
......@@ -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)
......
......@@ -30,6 +30,8 @@
#include <string>
#include <boost/config.hpp>
#include "ossimPluginConstants.h" // OSSIM_PLUGINS_DLL
#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimFilename.h>
#include <ossim/base/ossimKeywordNames.h>
......@@ -37,7 +39,6 @@
#include <ossim/base/ossimRefPtr.h>
#include "ossim/ossimSarSensorModel.h"
#include "ossimPluginConstants.h" // OSSIM_PLUGINS_DLL
#include <ossim/support_data/ossimSupportFilesList.h>
......
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