Tricky Bug

Sometimes when using the Opening source tools, i will encounter weird bug or feature, most of it because i am using it in a unique way.

1. NPM CONFIG Auth

when npm is using the private registry, like the Nexus, it will require Token for npm to access it

generally we can use in this way

script
1
2
3
4
export NPM_CONFIG_STRICT_SSL=false
export NPM_CONFIG_ALWAYS_AUTH=true
export NPM_CONFIG__AUTH=xxxx
npm ping --registry https://xxx.xxx.xxx/

you might have noticed that for the AUTH env it has two underscore instead of one
actually it is a feature of NPM, and it is merged into the tool since 2014
refer link: https://github.com/npm/cli/issues/3985

Solution:
Use NPM_CONFIG__AUTH

2. Docker Config

When many users are using docker on Jenkins, we can restrict user by locking the Global Config

script
1
2
3
4
5
6
7
touch /var/log/gitconfig
ln -s var/log/gitconfig /home/user/.gitconfig

touch /var/log/dockerconfig.json
mkdir /home/user/.docker
chmod 600 /home/jenbld/.docker
ln -s /var/log/dockerconfig.json /home/user/.docker/config.json

and we can export home=${workspace}, to use the local config under workspace
There comes with a plugin problem:

The “Docker Build and Publish plugin” will fail on “Failed to deserialize Rejected”.

see the changes:
https://github.com/moby/moby/commit/18c9b6c6455f116ae59cde8544413b3d7d294a5e
change from .dockercfg to config.json

Solution:
upgrade your plugin or use the deprecated config .dockercfg

3. Terraform init

when you run terraform init on laptop you might encounter

1
2
3
4
5
6
7
8

│ Error: Failed to query available provider packages

│ Could not retrieve the list of available versions for provider
│ hashicorp/google: could not connect to registry.terraform.io: Failed to
│ request discovery document: Get
│ "https://registry.terraform.io/.well-known/terraform.json": proxyconnect
│ tcp: EOF

it might because the proxy issue, set on the vpn and set proxy
export https_proxy=’http://127.0.0.1:7890' then will be fine

when you encounter “Error: storage.NewClient() failed: dialing: google: could not find default credentials”
during terraform init, just add the credentials = “../key.json” to backend.tf to fix it