game-ci / game-ci/documentation
Google CloudBuild doesn't detect Licence
- Dominant language
- MDX
- Stars
- 243
- Forks
- 130
- Avg merge
- 15d 42m
- Merged PRs (30d)
- 1
Description
**Bug description**
### Context
I'm trying to setup the CI pipeline in Google CloudBuild.
### Steps
- I've followed carefully all the steps porting the gitlab pipeline example over.
- I've generated and activated the license successfully. The generation was done in a CloudBuild runner and the activation manually in the unity website.
- I've encoded to base64 the licence and added it as a secret environment variable. Then decoded it before saving it to disk.
### Findings
The `before_script.sh` is running fine and writing to disk the licence at: `/root/.local/share/unity3d/Unity/Unity_lic.ulf`
I've also inspected the licence by `cat /root/.local/share/unity3d/Unity/Unity_lic.ulf` and it matches with the one i've downloaded.
### The Problem
The problem i'm having is that when the `build.sh` is running it seems that doesn't detect the license file located in `/root/.local/share/unity3d/Unity/Unity_lic.ulf` and so it tries to generate a new license to activate.
Here is the output I'm getting:
```bash
docker.io/unityci/editor:2021.3.6f1-webgl-1.0.1
+ mkdir -p /root/.cache/unity3d
+ mkdir -p /root/.local/share/unity3d/Unity/
+ set +x
Writing '$UNITY_LICENSE' to license file /root/.local/share/unity3d/Unity/Unity_lic.ulf
+ echo 'Building for WebGL'
+ export BUILD_PATH=/workspace/Builds/WebGL/
+ BUILD_PATH=/workspace/Builds/WebGL/
+ mkdir -p /workspace/Builds/WebGL/
Building for WebGL
+ cat /root/.local/share/unity3d/Unity/Unity_lic.ulf
[REDACTED LICENCE OUTPUT]
Branch: 2021.3/staging
Build type: Release
Batch mode: YES
System name: Linux
Distro version: #1 SMP Debian 5.10.127-1 (2022-06-30)
Kernel version: 5.10.0-16-cloud-amd64
Architecture: x86_64
Available memory: 3930 MB
[LicensingClient] Channel doesn't exist: "LicenseClient-root"
[Licensing::Module] Successfully launched the LicensingClient (PId: 59)
[SignatureVerifier] Application signature verification not supported on this platform.
[LicensingClient] Handshaking with LicensingClient (version: 1.9.0+249add7)
[Licensing::Module] Successfully connected to LicensingClient on channel: "LicenseClient-root" (connect: 1.37s, validation: 0.20s, handshake: 0.00s)
[Licensing::Module] Connected to LicensingClient (PId: 59, launch time: 0.00, total connection time: 1.57s)
Entitlement-based licensing initiated
[Licensing::Module] Error: Access token is unavailable
[LicensingClient] Licenses updated successfully
[UnityConnectServicesConfig] config is NOT valid, switching to default
Cancelling DisplayDialog: Failed to activate/update license Missing or bad username or password. Please try again using valid credentials or contact support@unity3d.com
This should not be called in batch mode.
```
cloud build:
```yaml
steps:
- name: unityci/editor:2021.3.6f1-webgl-1.0.1
secretEnv: ['UNITY_LICENCE']
entrypoint: "bash"
args:
- "-c"
- |
chmod +x ./ci/before_script.sh ./ci/build.sh && ./ci/before_script.sh && ./ci/build.sh
```
### Ugly workaround
If i run the job by using "docker in docker" it seems to work correctly, for example, given the following configuration:
```yaml
steps:
- name: gcr.io/cloud-builders/docker
secretEnv: ['UNITY_LICENCE']
entrypoint: 'bash'
args:
- -c
- |
docker run --ipc=host \
-e BUILD_TARGET="$$BUILD_TARGET" \
-e BUILD_NAME=$$BUILD_NAME \
-e UNITY_DIR=$$UNITY_DIR \
-e VERSION_NUMBER_VAR=$$VERSION_NUMBER_VAR \
-e VERSION_BUILD_VAR=$$VERSION_NUMBER_VAR \
-e UNITY_LICENCE="$$UNITY_LICENCE" \
-w /project/ \
-v /workspace:/project/ \
unityci/editor:2021.3.6f1-webgl-1.0.1 \
/bin/bash -c "chmod +x /project/ci/before_script.sh /project/ci/build.sh && /project/ci/before_script.sh && /project/ci/build.sh"
env:
- 'BUILD_TARGET=WebGL'
- 'BUILD_NAME=ShoppingMall'
- 'UNITY_DIR=/project'
- 'VERSION_NUMBER_VAR=$SHORT_SHA'
- 'VERSION_BUILD_VAR=$REVISION_ID'
```
**Steps to reproduce**
Simply try to run the following job in cloudbuild:
```yaml
steps:
- name: unityci/editor:2021.3.6f1-webgl-1.0.1
env:
- 'UNITY_LICENCE=LICENCE_BASE64_HERE'
entrypoint: "bash"
args:
- "-c"
- |
chmod +x ./ci/before_script.sh ./ci/build.sh && ./ci/before_script.sh && ./ci/build.sh
```
alter the before_script.sh to decode the variable, for example:
```
echo -n $UNITY_LICENCE | base64 -d | tr -d '\r' > ${unity_license_destination}
```
**Expected behavior**
The cloudbuild runner picks up the license when running the `build.sh` script
**Additional details**
Contributor guide
Assessment
This issue has not been assessed yet.