Loading all/.gitlab-ci.yml +19 −13 Original line number Diff line number Diff line Loading @@ -27,30 +27,36 @@ Validate OpenAPI: - | curl "${CI_API_V4_URL}/projects/57/repository/files/all%2Fvalidate-all-in-docker%2Esh/raw?ref=master" >> validate-all-in-docker.sh - chmod +x validate-all-in-docker.sh script: - echo 'Validate OpenAPI' - docker run --rm -v $(pwd):"/specs" etsiforge/swagger-cli:4.0.3 /bin/sh -c "sh specs/validate-all-in-docker.sh" #- ./validate-all.sh $(pwd) artifacts: name: "$CI_JOB_NAME" paths: - ${LOGFILE_OPENAPI} Generate config: stage: generation when: always before_script: - | curl "${CI_API_V4_URL}/projects/57/repository/files/all%2Fgenerate-config%2Esh/raw?ref=master" >> generate-config.sh - chmod +x generate-config.sh script: - echo 'Validate OpenAPI' - docker run --rm -v $(pwd):"/specs" etsiforge/swagger-cli:4.0.3 /bin/sh -c "sh specs/validate-all-in-docker.sh" - echo 'Generate config' - ./generate-config.sh $(pwd) #- ./validate-all.sh $(pwd) artifacts: name: "$CI_JOB_NAME" paths: - ${LOGFILE_OPENAPI} - api-versions.txt # Generate config: # stage: generation # when: always # before_script: # - | # curl "${CI_API_V4_URL}/projects/57/repository/files/all%2Fgenerate-config%2Esh/raw?ref=master" >> generate-config.sh # - chmod +x generate-config.sh # script: # - echo 'Generate config' # - ./generate-config.sh $(pwd) # artifacts: # name: "$CI_JOB_NAME" # paths: # - api-versions.txt CR contribution: stage: generation when: on_success Loading all/generate-config.sh +1 −15 Original line number Diff line number Diff line #!/bin/bash # Copyright ETSI 2021 # See: https://forge.etsi.org/etsi-forge-copyright-statement.txt echo "------ Content of the folder ------" ls # If there are no YAML file, simply exit ls | grep -q yaml found_yaml=$? Loading @@ -17,18 +14,10 @@ echo "------ Installing necessary node modules -----" npm install js-yaml npm install json pwd echo "------ Removing old CONFIG file ------" #rm -f api-versions.txt echo "------ Generating CONFIG file from all YAML files ------" echo "------ Switching to $1 folder --------" #cd $1 #pwd fres=0 for i in $1/*.yaml ; do for i in *.yaml ; do echo "[$i]" echo "[$i]" | grep -Po "TS[\w-]+\.yaml" | xargs -I % sh -c 'echo [%]' >> api-versions.txt ; node ./node_modules/js-yaml/bin/js-yaml $i > "$i.json" ; Loading @@ -49,7 +38,4 @@ for i in $1/*.yaml ; do res=$? fres=$(($fres||$res)) done # Exit code needed for jenkins to know the verdict of the build echo "-- Final validator returns $fres." exit $fres all/validate-all-in-docker.sh +8 −7 Original line number Diff line number Diff line Loading @@ -17,14 +17,14 @@ ERR="" for i in specs/*.yaml do #echo -e "---- Validating $i ... " swagger-cli validate "$i" MSG=$(swagger-cli validate "$i" 2>&1) #MSG=$(validate "$i" 2>&1) #echo "$MSG" echo "$MSG" res=$? # if [ ! $res == 0 ] ; then # ERR="$ERR$MSG\n" # fi # LOG="$LOG$MSG\n" if [ ! $res == 0 ] ; then ERR="$ERR$MSG\n" fi LOG="$LOG$MSG\n" fres=$(($fres||$res)) done echo -e "\n-- Final validator returns $fres." | tee -a $LOGFILE Loading @@ -43,5 +43,6 @@ echo -e "\n---- Complete log of validation ----" | tee -a $LOGFILE echo -e $LOG | tee -a $LOGFILE #echo -e "\n------ Content of the folder ------" | tee -a $LOGFILE #ls | tee -a $LOGFILE mv $LOGFILE specs/ # Exit code needed for jenkins to know the verdict of the build exit $fres No newline at end of file Loading
all/.gitlab-ci.yml +19 −13 Original line number Diff line number Diff line Loading @@ -27,30 +27,36 @@ Validate OpenAPI: - | curl "${CI_API_V4_URL}/projects/57/repository/files/all%2Fvalidate-all-in-docker%2Esh/raw?ref=master" >> validate-all-in-docker.sh - chmod +x validate-all-in-docker.sh script: - echo 'Validate OpenAPI' - docker run --rm -v $(pwd):"/specs" etsiforge/swagger-cli:4.0.3 /bin/sh -c "sh specs/validate-all-in-docker.sh" #- ./validate-all.sh $(pwd) artifacts: name: "$CI_JOB_NAME" paths: - ${LOGFILE_OPENAPI} Generate config: stage: generation when: always before_script: - | curl "${CI_API_V4_URL}/projects/57/repository/files/all%2Fgenerate-config%2Esh/raw?ref=master" >> generate-config.sh - chmod +x generate-config.sh script: - echo 'Validate OpenAPI' - docker run --rm -v $(pwd):"/specs" etsiforge/swagger-cli:4.0.3 /bin/sh -c "sh specs/validate-all-in-docker.sh" - echo 'Generate config' - ./generate-config.sh $(pwd) #- ./validate-all.sh $(pwd) artifacts: name: "$CI_JOB_NAME" paths: - ${LOGFILE_OPENAPI} - api-versions.txt # Generate config: # stage: generation # when: always # before_script: # - | # curl "${CI_API_V4_URL}/projects/57/repository/files/all%2Fgenerate-config%2Esh/raw?ref=master" >> generate-config.sh # - chmod +x generate-config.sh # script: # - echo 'Generate config' # - ./generate-config.sh $(pwd) # artifacts: # name: "$CI_JOB_NAME" # paths: # - api-versions.txt CR contribution: stage: generation when: on_success Loading
all/generate-config.sh +1 −15 Original line number Diff line number Diff line #!/bin/bash # Copyright ETSI 2021 # See: https://forge.etsi.org/etsi-forge-copyright-statement.txt echo "------ Content of the folder ------" ls # If there are no YAML file, simply exit ls | grep -q yaml found_yaml=$? Loading @@ -17,18 +14,10 @@ echo "------ Installing necessary node modules -----" npm install js-yaml npm install json pwd echo "------ Removing old CONFIG file ------" #rm -f api-versions.txt echo "------ Generating CONFIG file from all YAML files ------" echo "------ Switching to $1 folder --------" #cd $1 #pwd fres=0 for i in $1/*.yaml ; do for i in *.yaml ; do echo "[$i]" echo "[$i]" | grep -Po "TS[\w-]+\.yaml" | xargs -I % sh -c 'echo [%]' >> api-versions.txt ; node ./node_modules/js-yaml/bin/js-yaml $i > "$i.json" ; Loading @@ -49,7 +38,4 @@ for i in $1/*.yaml ; do res=$? fres=$(($fres||$res)) done # Exit code needed for jenkins to know the verdict of the build echo "-- Final validator returns $fres." exit $fres
all/validate-all-in-docker.sh +8 −7 Original line number Diff line number Diff line Loading @@ -17,14 +17,14 @@ ERR="" for i in specs/*.yaml do #echo -e "---- Validating $i ... " swagger-cli validate "$i" MSG=$(swagger-cli validate "$i" 2>&1) #MSG=$(validate "$i" 2>&1) #echo "$MSG" echo "$MSG" res=$? # if [ ! $res == 0 ] ; then # ERR="$ERR$MSG\n" # fi # LOG="$LOG$MSG\n" if [ ! $res == 0 ] ; then ERR="$ERR$MSG\n" fi LOG="$LOG$MSG\n" fres=$(($fres||$res)) done echo -e "\n-- Final validator returns $fres." | tee -a $LOGFILE Loading @@ -43,5 +43,6 @@ echo -e "\n---- Complete log of validation ----" | tee -a $LOGFILE echo -e $LOG | tee -a $LOGFILE #echo -e "\n------ Content of the folder ------" | tee -a $LOGFILE #ls | tee -a $LOGFILE mv $LOGFILE specs/ # Exit code needed for jenkins to know the verdict of the build exit $fres No newline at end of file