How to set application credential details in CI? - continuous-integration

How to set application credential details in buildkite so that it can be used as part of tests?
Any help?
thanks in Advance

The easiest way is to store them in an agent environment hook, which is a script file you need to put on the host running the agent, and is invoked just before every job the agent runs:
# /etc/buildkite-agent/hooks/environment
set -eu
echo "--- :house_with_garden: Setting up the environment"
export APPLICATION_PASSWORD="xxx"
and then use them in your pipeline commands from the environment:
# .buildkite/pipeline.yml
steps:
- label: Run tests
command: ./run-tests --password="$$APPLICATION_PASSWORD"
The double-dollar escapes the variable for pipeline upload, making sure that the password is not interpolated into the YAML and then submitted to buildkite.com. It will then be interpolated once the agent runs the command.
You could also access $APPLICATION_PASSWORD within your script to avoid mentioning it in the yaml at all.
The agent environment hook works best if you're running long lived agents, or use something like the elastic-ci-stack-for-aws which has a shared environment hook for this sort of thing:
https://github.com/buildkite/elastic-ci-stack-for-aws#build-secrets
but there are a few other options, too:
https://buildkite.com/docs/pipelines/secrets

Related

Jenkins shell fetching secret txt

I have a secret txt and want to pass the Variables in the Jenkins Shell script (Not the Pipeline)
Need help on this
withCredentials([string(credentialsId: 'API_TOKEN_ID', variable: 'TOKEN_VALUE')])
the above works in shell script inside the pipeline, but want to execute this in "Execute Shell" mode in Jenkins.
You may try this : https://plugins.jenkins.io/credentials-binding/
If it’s a token you can put it as an env variables

sqlplus command not found zabbix

I'm working and discovering the world of Zabbix. In particular I am trying to monitor an Oracle database with the Zabbix server through an external script. Given that other external scripts work, however, I created one with sqlplus, but on Zabbix I get "command not found". Can you tell me why?
The code is:
check.pl
#!/usr/bin/perl
use strict;
use warnings;
my $out=`echo "select * from v$version;" | sqlplus user/password#ip_database:port`;
print $out;
The code is very simple.
I created an item as always, passed as type "external check" and a key I entered my script. Can anyone solve my problem? Also if I was not clear, just ask for more information rather than "insult" on the forum: Thanks to everyone in advance
I RESOLVED IT WITH:
echo "/usr/lib/oracle/11.2/client64/lib" > /etc/ld.so.conf.d/oracle.conf
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/11.2/client64/lib" >> /etc/profile
THANKS TO ALL!!!!
Apparently, your zabbix server does not have the necessary environment to find sqlplus. You could simply use the full path to sqlplus in your script (but that alone might not be enough) or create a wrapper script that sets all the necessary environment variables for your script.
From TFM:
The command will be executed as the user Zabbix server runs as, so any
access permissions or environment variables should be handled in a
wrapper script, if necessary, and permissions on the command should
allow that user to execute it.
You also have to configure the sqlplus libraries required to run sqlplus. The script which you use to start the zabbix server you can configure below oracle things in the startup script so that zabbix can find all necessary libraries to run.
export ORACLE_HOME={path to Oracle Client}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib
If still there are issues related to .so files then there must be some issues in your SQL client installation.

Jenkins - Passing variable password to external shell

I am using the BUILD STEP "Execute shell script on remote host" and I'm injecting a password to my project:
The jenkins call a script.sh, but the script does not print variable PASS passed by jenkins.
As a step variable issued by Jenkins to my external script?
PASS=${PASSWORD}
echo PASSWORD=$PASS
sh /root/script.sh
You need to export your variable in order to make it available to subshells:
export PASS=${PASSWORD}
If you don't want other programs you invoke in the same script to see your password, consider this safer way:
PASS=${PASSWORD} /root/script.sh

Jenkins - Execute Shell Build Step Not Working

I'm trying to create a job in Jenkins that will execute a simple shell script. However, it seems that Jenkins isn't actually doing anything with my script. No matter what value I put into the Execute Shell Command section, Jenkins always says that it passes. Even if I put in a bogus filename like "RandomBogusFilename.sh" it'll say the job was a success.
Can anyone point out what I'm doing wrong and how I can get Jenkins to actually use my shell script?
The shell script, the job config, and the console output are all shown below. I'm currently trying to do this on a Windows Server 2008 R2 Standard machine.
Thanks.
My .sh file
File Name: surveyToolRequest.sh
File Location: /jobs/Jeff Shell Script Test/workspace
Description:
Hit a web address and retrieve the HTTP Response. Then print out the HTTP Response.
#!/bin/bash
response_code=$(curl -s -o /dev/null -w "%{http_code}" http://SOME-WEBSITE.COM)
echo "The response code is " $response_code
My Jenkins Job Config
Jenkins Console Output
I played with this and found that it worked if I specified the path to the script. If the script is in your job's workspace directory,
./surveyToolRequest.sh
should work as Jenkins looks for files relative to the root of the workspace.
It's more common to just put the contents of the script file directory into the job configuration; that way you can see what the job is doing and you'll avoid problems like this one.
You should use run "Execute windows batch command" and not "Execute Shell"

How to set environment variable using Chef?

Theres a similar question to this, but cant manage it to work:
I want to simply set an env variable, then use it:
execute "start zookeeper" do
cwd "/opt/zookeeper-3.4.5/bin"
command "./zkServer.sh start"
environment "JVMFLAGS" => "-Xmx#{heap_jvm} -Xms#{heap_jvm}"
user "root"
action :run
end
I've also tried using bash to "export JVMFLAGS='-blabla'" but still it runs the sh with none set to the variable. Is there some issue preventing my sh script from checking the variable?
I could use the sh like a template and replace the ocurrence of JVMFLAGS... But i want to check if theres a better solution..
Have you tried setting environment variable through Ruby just before the execute block? Chef actually recommends using ENV (See the note on that page).
ENV['JVMFLAGS'] = "-Xmx#{heap_jvm} -Xms#{heap_jvm}"
Another possibility is to add JVMFLAGS to the command itself.
execute "start zookeeper" do
[...]
command "JVMFLAGS=-Xmx#{heap_jvm} -Xms#{heap_jvm} ./zkServer.sh start"
[...]
end

Resources