- dont forget to use . when create .gitlab-ci.yaml file
- put it on root directory and it will auto detected by gitlab system
- setting up runner (ask help from SRE team)
- put sensitif data in gitlab ci variable
tools : filetobase64
use this code below to decode from base64 to file
- echo $YOUR_GITLAB_CI_VARIABLE | base64 -di > your-file-name.extension
- use docker image version same as local version of sdk
example : image: ghcr.io/cirruslabs/flutter:3.13.2
will be better if we clone the image to our server
- gitlab ci script does not support multi line, make it single line and separate each script with semicolon ;
- don't forget to use tags: or your pipeline will not detected by runner
- generate version from git tag
#!/bin/bash # Set ENVIRONMENT to either "sandbox" or "prod" for testing ENVIRONMENT="sandbox" BUILD_NUMBER="" # Example for testing: if [ "$ENVIRONMENT" != "prod" ]; then BUILD_NUMBER="20012003" # Example 8 digits for sandbox elif [ "$ENVIRONMENT" == "prod" ]; then BUILD_NUMBER="201002" # Example 6 digits for prod fi # Generate the build name based on the length of the BUILD_NUMBER if [ ${#BUILD_NUMBER} -eq 8 ]; then # Sandbox format: 8 digits -> 2.1.2.30 (apply the same logic as prod) BUILD_NAME=$(echo $BUILD_NUMBER | sed -r 's/^([0-9])([0-9]{0,1})([0-9]{1,2})([0-9]{1,2})([0-9]{2})$/\1.\2\3.\4.\5/' | sed -r 's/\.0([0-9])/\.\1/g; s/\.0+([1-9][0-9]*)/\.\1/g; s/^([0-9]+)\.0+([0-9]+)/\1.\2/') elif [ ${#BUILD_NUMBER} -eq 6 ]; then # Prod format: 6 digits -> 2.1.20 BUILD_NAME=$(echo $BUILD_NUMBER | sed -r 's/^([0-9])([0-9]{0,1})([0-9]{1,2})([0-9]{2})$/\1.\2\3.\4/' | sed -r 's/\.0([0-9])/\.\1/g; s/\.0+([1-9][0-9]*)/\.\1/g; s/^([0-9]+)\.0+([0-9]+)/\1.\2/') fi # Output the results echo "ENVIRONMENT: $ENVIRONMENT" echo "BUILD_NUMBER: $BUILD_NUMBER" echo "BUILD_NAME: $BUILD_NAME"
Komentar
Posting Komentar