I found this answer Integrate Postman test scripts with Jenkins build server (and possibly there are other ones that could answer my question but I just suck at finding them) but I am still running into issues. I am trying to execute the following with newman v3 using jenkins as a way to automate our REST API Testing.
My Execute Shell script looks like this under the Build steps in the jenkins job
#!/bin/bash
pwd
cd ${PROJECT_NAME}/${GIT_SUBFOLDER}
pwd
ls
newman run ${COLLECTION_NAME} -e ${ENVIRONMENT_NAME} -r html,cli,json,junit --insecure
Ignore the pwds and ls as I originally thought I wasn't in the right directory for my collection and environment exports.
The error I keep getting back in jenkins is:
/tmp/hudson1153303836033593524.sh: line 6: newman: command not found
Any help would be greatly appreciated!
Got your problem, Seems that you are trying to execute your project as shell script in jenkins and jenkins cant get newmanHere is the solution, might solve your problemIn your script export path where npm modules get installedLocate node_modules for your system generally its at /usr/local/lib/node_modulesNow add line in your script which will export PATH:
#!/bin/bash
export PATH="<Your node_module Path>:$PATH"
pwd
cd ${PROJECT_NAME}/${GIT_SUBFOLDER}
pwd
ls
newman run ${COLLECTION_NAME} -e ${ENVIRONMENT_NAME} -r html,cli,json,junit --insecure
Related
So after spending half a day as our surprise jenkins devops guy, I'm not sure if this scenario is even possible.
We have a linux Jenkins server that runs a groovy file to build some of our software. Recently we moved from dropbox to onedrive and one of my tasks is to change all our CI apps to upload files to onedrive. Using appveyor and powershell I was able to do this, but Jenkins is giving me problems. I was hoping to re-use the powershell scripts I wrote for appveyor, tweak them, and use them in the Jenkins pipeline. I've installed the Powershell plugin on our Jenkins server, but it's still not finding powershell. I've tested the GetAccessToken.ps1 script locally (but I'm on w10), and it's fine.
Groovy code snippet
stage('Deploy')
{
environment
{
ONEDRIVE_ID = credentials('OneDriveClientId')
ONEDRIVE_SECRET = credentials('OneDriveSecretKey')
ONEDRIVE_TOKEN = powershell "Common/Build/GetAccessToken.ps1 ${ONEDRIVE_ID} ${ONEDRIVE_SECRET}"
}
steps
{
echo 'Deploying Code....'
sh "chmod +x Common/Build/UploadToOnedrive.ps1"
powershell "Common/Build/UploadToOnedrive.ps1 -t ${ONEDRIVE_TOKEN} -s bootloader/redacted/Build/redacted-f redacted -v ${VERSION} -b ${BRANCH_NAME}"
}
}
Error
Caused: java.io.IOException: Cannot run program "powershell" (in directory "/var/lib/jenkins/workspace/test_branch"): error=2, No such file or directory
I've tried about 10 different ways of calling the script, based on other SO posts and jenkins.io posts, and I get varying degrees of failure. I'm wondering if I need a Windows slave to run powershell (although I thought the plugin would allow me to). Last resort I'll just try to alter the old bash scripts to upload using curl but I was really hoping to use the powershell scripts.
Oh, and here's my PATH. I think I read that pwsh/powershell gets installed in /usr/local/sbin or /usr/local/bin so that shouldn't be the issue
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Thanks to Shane's sanity check, I was able to install pwsh on the Jenkins ubuntu server and then my groovy pwsh steps started working. I'm still having some issues passing variables but that's for another topic. I'm now able to use scripts like this in my groovy script
environment {
ONEDRIVE_TOKEN = pwsh (script: "Common/Build/GetAccessToken.ps1 ${env.ONEDRIVE_ID} ${env.ONEDRIVE_SECRET}", returnStdout: true)
}
Update; here is how I'm able to call a powershell script from groovy with variables
sh 'pwsh Common/Build/UploadToOnedrive.ps1 -t $ONEDRIVE_TOKEN -s "Release" -f "testname" -v $VERSION -b $BRANCH_NAME'
If I run the command:
pipenv shell
in my Mac shell, everything works fine and a new virtual environment is created and activated:
.../django_celery_rabbit_flower$ pipenv shell
Launching subshell in virtual environment...
bash: parse_git_branch: command not found
.../django_celery_rabbit_flower$ . /.../django_celery_rabbit_flower-rEt8HW1V/bin/activate
bash: parse_git_branch: command not found
(django_celery_rabbit_flower) .../django_celery_rabbit_flower$
but a bash error is displayed:
bash: parse_git_branch: command not found
I do not understand where it come from. Any idea?
UPDATE
Jen answer trigger a little thought. I have checked my ./bash_profile and I can see the line:
export PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$(parse_git_branch)\$ "
This shows the git branch on the bash prompt. So I believe vscode uses this settings. The folder I am working on is not a git folder. Can I write an if statement to avoid the error being displayed when running the python virtual environment?
Instead make sure that the command does actually exists before running it.
PS1="...."'$(if hash parse_git_branch >/dev/null 2>&1; then parse_git_branch; fi)'"..."
I am creating a bash script in Linux (ubuntu) that starts an ant build from a build.xml file, located in another directory. My folder structure looks like this:
myBashScript.sh
/project56
/http
build.xml
When I try to call this build file from myBashScript.sh I get the following error:
"Buildfile project56/http/buildfile.xml does not exist!"
I tried the following:
sudo ant -buildfile project56/http/build.xml
sudo ant -v project56/http/build.xml
sudo ant -v fullPathStartingFromHome/build.xml
But I keep getting this error. The funny thing is, when I try to invoke ant (using the first option listed above) from the terminal in the same location that myBashScript.sh is in, the build starts fine.
Can someone help me with this?
Thanks in advance,
Robert
Fixed it, turns out another cd to project56 buried somewhere in my script was screwing things up.
I am trying to run the following command:
/A/B/C/D/E/RAILS_ENV=staging rake deploy:resque
And the get the following error
-bash: /A/B/C/D/E/RAILS_ENV=staging: No such file or directory
But when i run the command directly from the folder it works nicely.
I don't quite understand how it is supposed to work
Thanks.
cd /A/B/C/D/E && RAILS_ENV=staging; rake deploy:resque
im following this guide to install OpenVPN on my FreeNAS system.
http://joepaetzel.wordpress.com/2013/09/22/openvpn-on-freenas-9-1/
I have ran in to the issues detailed below when trying to create the CA.cert.
[root#freenas] /mnt/NAS/openvpn# chmod -R 755 easy-rsa/2.0/*
[root#freenas] /mnt/NAS/openvpn# cd easy-rsa/2.0
[root#freenas] /mnt/NAS/openvpn/easy-rsa/2.0# sh
#./clean-all
Please source the vars script first (i.e. "source ./vars")
Make sure you have edited it to reflect your configuration.
# . ./vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /mnt/NAS/openvpn/easyrsa/2.0/keys
# ./build-ca
Please edit the vars script to reflect your configuration,
then source it with "source ./vars".
Next, to start with a fresh PKI configuration and to delete any
previous certificates and keys, run "./clean-all".
Finally, you can run this tool (pkitool) to build certificates/keys.
I have tried creating the keys directory manually as i have read this has worked for others but still no luck. Being new to BSD I've hit a road block and looking for some advice.
Any ideas?
cheers guys
UPDATE:
When trying to source ./vars i get the following output
[root#freenas] /mnt/NAS/openvpn/easy-rsa/2.0# source ./vars
export: Command not found.
export: Command not found.
export: Command not found.
export: Command not found.
EASY_RSA: Undefined variable.
export: Command not found.
EASY_RSA: Undefined variable.
FreeNAS's default shell is not sh, and therefore doesn't support the 'export' command. The ./vars script needs the export command to set environment variables it then needs.
So before you call ./vars (don't call source) call:
sh
This is clearly stated in the site: http://joepaetzel.wordpress.com/2013/09/22/openvpn-on-freenas-9-1/
Not sure about the original issue, i think nrathaus has covered that well.
demonLaMagra - If you want to check if openvpn in running use this command:
service openvpn status
Sorry I couldn't comment on the last answer because of being a new new user, otherwise I would have.