How can i make my curl command work in gitlab-ci? - powershell

I have curl that i use in gitlab-ci job to upload an artifact to Nexus
the command is as follow (defined in .gitlab-ci.yml under script section)
cmd /c curl -v -u $env:USERREG:$env:PASSREG --upload-file $env:BINFILE $env:NEXUS_REGISTRY/$env:REPONAME$env:BINFILE
of course all the variables are declared in .gitlab-ci.yml file except for USERREG and PASSREG which i declared them using the gitlab GUI.
Notice that i am using:
- Gitlab Runner with docker-windows executor
- Windows docker container to exec the above command
PROBLEM : the job is stacked demanding for the user (defined by USERREG) password (PASSREG) until the job is terminated due to timeout.
How to fix this problem ? thank you.

I am not sure if this could be your problem, but please check and refer to the GitLab Variables which you set ( USERREG and PASSREG). If they are protected variables that means that they will be only available on a "protected" branches and in case you are pushing it from non-protected branch that could brings you to the state where you are currently because above mentioned variables are not available.
If this is the case, just make them to not be protected but masked and you should be fine.

Related

Cypress Error in sending multiple parameters via CLI

I'm using below command in my terminal.(Im following the cypress support doc)
cypress run --env host=kevin.dev.local,api_server=http://localhost:8888/api/v1
my spec is like this.
I'm expecting to set variables as below:
host=kevin.dev.local
api_server=http://localhost:8888/api/v1
But it does not set the value of the "api_server". Instead it sets host with both values as below:
host=kevin.dev.local http://localhost:8888/api/v1
Pls support to get this resolved.
You shell might interpret some of the characters before passing them to Cypress.
When I run in Powershell the following command:
> cypress open --env a=1,b=2
I'll end up in the same situation like described.
When I run:
> cypress open --env "a=1,b=2"
It will correctly set two env variables a and b with correct values.
So, try using double quotes.

Multiple (github) PR checks from single azure pipeline yaml

Maybe i'm missing something obvious, but...
Can i have several (github) PR checks from a single azure pipelines yaml?
For example, on this screenshot i have CI connected to azure pipelines where build & running tests happen within the same check:
Can i somehow separate them so i have 2 checks: Build and running tests and see them pass|fail separately?
if its possible to have N checks in a single yaml and have their
statuses posted separately
For this issue, the answer is yes, you can achieve this with script approach.
Here is an issue about Multiple GitHub checks, in this issue, someone has the same problem as you, and got a solution and the exact config is given in it.
Since the build environment is a shell, for example, you could wrap your lint commands in a shell script that traps the exit code and sends the status to GitHub:
#!/bin/sh
npm run lint
EXIT_CODE=$?
if [[ $EXIT_CODE == 0 ]]
then
export STATUS="success"
else
export STATUS="failure"
fi
GITHUB_TOKEN=<your api token>
curl "https://api.github.com/repos/$CI_REPO/statuses/$CI_COMMIT?access_token=$GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d "{\"state\": \"$STATUS\", \"description\": \"eslint\", \"target_url\": \"$CI_BUILD_URL\"}"
exit $EXIT_CODE

Building Artifactory fails for Build Stage in Delivery Pipeline

I have created a toolchain, which downloads the code from the bitbucket repository and builds the docker image in IBM Cloud.
After the code builds the image, the build stage fails while building the artifactory.
Error:
Preparing the build artifacts...
Customer script does not exist for the job, exitting
I have specified the Build archive directory as the folder name. Do I need to write any scripts for archiving?
That particular error occurs when one of our checks -- the existence of /home/pipeline/$TASK_ID/_customer_script.sh -- fails.
Archiving happens automatically but that file needs to be present as we use it as part of the traceability around how the artifact was created. Is it possible that file is getting removed? (Also will look into removing or making the check non-fatal however that will take time)
This issue appears to be caused by setting a working directory for the job. _customer_script.sh gets dropped into the working directory, but the script Simon is referring to (/opt/IBM/pipeline/bin/ids-buildables-notify.sh) only checks the top-level directory the code input is at (/home/pipeline/$TASK_ID/).
Three options to fix this, assuming you're doing a container registry job:
Run cp _customer_script.sh /home/pipeline/$TASK_ID in your script. The ids-buildables-notify.sh script does some grepping for your bx cr build call, so make sure that's still in there.
touch /home/pipeline/$TASK_ID/_customer_script.sh and export PIPELINE_IMAGE_URL=<your image url>. If PIPELINE_IMAGE_URL is set, the notify script doesn't bother with being clever, which I prefer.
Don't change the working directory.
A script which works for me:
#!/bin/bash
echo -e "Build environment variables:"
echo "REGISTRY_URL=${REGISTRY_URL}"
echo "REGISTRY_NAMESPACE=${REGISTRY_NAMESPACE}"
echo "IMAGE_NAME=${IMAGE_NAME}"
echo "BUILD_NUMBER=${BUILD_NUMBER}"
echo -e "Building container image"
set -x
export PIPELINE_IMAGE_URL=$REGISTRY_URL/$REGISTRY_NAMESPACE/$IMAGE_NAME:$BUILD_NUMBER
bx cr build -t $PIPELINE_IMAGE_URL .
set +x
touch /home/pipeline/$TASK_ID/_customer_script.sh

How do I set an environment variable on Windows 10, which was generated from GitHub?

I want to make an updater for my Electron application, and I stuck on the GitHub access token.
I have generated a token from my GitHub account, and after that, I tried to set that token in my Windows environmental variables.
When I go to my application and I run this file publish.sh
publish.sh
#!/bin/sh
if [ -z "$GH_TOKEN" ]; then
echo "You must set the GH_TOKEN environment variable."
echo "See README.md for more details."
exit 1
fi
# This will build, package and upload the app to GitHub.
node_modules/.bin/build --win --mac -p always
I run this file ./publish.sh and I get this message:
You must set the GH_TOKEN environment variable.
I want to achieve step 4 and 5 in this example:
https://github.com/iffy/electron-updater-example
I tried to run this command from the Git Bash export GH_TOKEN="435468246872235283762846848267", but I get a return code of 0.
How do I set an environment variable on Windows 10, which was generated from GitHub?
Make sure to restart a new CMD session (in which you can type bash) in order to make sure your session does inherit the new Windows environment variable you have just set.
Once you have done that, you can check in the (new) Git Bash session which are the environment variables already set, with:
env
env | grep GH
Make sure your script starts with
#!/bin/bash
The OP George points out in the comments that the correct form is:
export GH_TOKEN=MY_VARIABLE_NAME
(no double quotes)

Why can't I read a property in BuildBot send from sendchange?

I am trying to send a property to a build configuration through a command line invocation of sendchange.
Here is a snippet of my master.cfg
factory = util.BuildFactory()
factory.addStep(
steps.ShellCommand(
command=["echo", util.Property('grid', default=2)]))
I am invoking the build using this command
buildbot sendchange --master my-server:9989 --auth me:mypass --who slineisitanyway --branch=master --property grid:5 a.txt
When I check the shell output in the web UI, I see that, indeed, the build did run, it succeeded, and it chose the default of 2, even though I have specified the property 'grid' on the command line.
Anyone know what I'm doing wrong?
You didn't specify revision. In this case Buildbot uses property from cache ;) I faced just same issue during testing.