Apply and Call : Both take first argument to change the its current context,
The call()
method takes arguments separately.
The apply()
method takes arguments as an array.
The call()
method takes arguments separately.
The apply()
method takes arguments as an array.
steps: # copy configuration bucket from GCS to cloudbuild - name: gcr.io/cloud-builders/gsutil args: ['cp', '-r', 'gs://${_GCS_CONFIGRATION_BUCKET}', '.'] # Set 400 to private key. - name: 'kroniak/ssh-client' args: ['chmod', '400', '${_GCS_CONFIGRATION_BUCKET}/ssh/cloudbuild_id_rsa'] # ssh into remote instance and run a script. - name: 'kroniak/ssh-client' args: ['ssh', '-i', '${_GCS_CONFIGRATION_BUCKET}/ssh/cloudbuild_id_rsa', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-p', '${_SSH_REMOTE_PORT}', '${_SSH_REMOTE_USER_HOST}', '${_SSH_REMOTE_COMMAND}']Because CloudBuild is stateless, you need to create your RSA keypairs and store the keys on a private GCS.
#!/bin/sh # It is good practice to print the required versions on server. # cause the code will execute in SSH non interactively mode. # https://stackoverflow.com/questions/17089808/how-to-do-remote-ssh-non-interactively echo "NodeJS: "$(node -v) echo "NPM: "$(npm -v) WORKSPACE=/working_directory/public_html echo "Working directory: " $WORKSPACE cd $WORKSPACE git checkout develop git pull -Xtheirs echo "===================Install dependencies ===========" npm install echo "===================Finished install dependencies ========" echo "RELOAD ENV" pm2 reload $WORKSPACE/ecosystem.config.js production --update-env
_GCS_CONFIGRATION_BUCKET : my-private-bucket-configuration _SSH_REMOTE_PORT : 2202 // hacker will sad. _SSH_REMOTE_USER_HOST : aduckdev@8.8.8.8 _SSH_REMOTE_COMMAND : /home/aduckdev/deployment_script.sh
replace({ '':'', '':'', '': '' })
Sadly, It was not enough,
$str = str_replace('', '', $str);
And here was the diff on Stash
function doAsync (){
return new Promise( (resolve, reason ) =>{
// do something to make error happens.
if(error){
throw new Error("ABC")
}
resolve("ok");
});
}
For the code, we have two solutions.
1.1 Use resolve with the error.
function doAsync (){
return new Promise( (resolve, reason ) =>{
// do something to make error happens.
if(error){
return reason( new Error("ABC") );
}
resolve("ok");
});
}
1.2 Use catch to return the error value.
function doAsync (){
return new Promise( (resolve, reason ) =>{
// do something to make error happens.
if(error){
throw new Error("ABC");
}
resolve("ok");
}).catch(err => errorHandling(err))
}
ssh your_username@server_address
ssh-keygen -t rsa - b 4096
cat ~/.ssh/id_rsa.pub
ssh your_username@server_address
cat ~/.ssh/id_rsa.pub | ssh your_username@server_address 'cat >> .ssh/authorized_keys'
ssh your_username@server_address ‘chmod 700 .ssh; chmod 640 .ssh/authorized_keys’
ssh your_username@server_address
sudo vim /etc/ssh/sshd_config
sudo systemctl restart ssh