Issue in creating jenkins job in saltstack - jenkins

I am trying to create a job on Jenkins, which is running in the salt minion.
When i run salt '*' jenkins.create_job test from salt master
I get error saying:
Module 'jenkins' is not available.
ERROR: Minions returned with non-zero exit code
can anyone please help me with this.

Most of modules in Saltstack if they are not available it will be because of the __virtual__ function which is responsible for the availability of the module is returning False. In your case the module is trying to check if Jenkins is available on the minion by trying to import jenkins in python if it fails to then jenkins module will be unavailable.
So what you need to do in order to check if that is the exact case you have to run the python interpreter on the minion system then call import jenkins if you got the following message No module named jenkins then you need to make sure that python-jenkins is installed on the minion system where you have Jenkins up and running. Also you can check its documentation if you need to.
Note: This module is for controlling Jenkins so you can only use it on a minion where Jenkins is installed.

Related

Ansible prompt with jenkins job

I'm running an Ansible playbook where I've added a "prompt" command to install one or other software depending on the user input.
At the playbook execution under Jenkins, there is :
"WARNING : Not waiting for response to prompt as stdin is not interactive".
I've been inspired by several topics as
pause ansible playbook for user confirmation, whether to run rest tasks
or
Ansible - Using user input to chose a variable
or
Ansible vars_prompt for roles
to make some tries, but the same WARNING appears each time.
I've wondered if there was a parameter to add in the ansible.cfg file to force the interactive mode, or something "mandatory" to write in the playbook (I've searched on https://docs.ansible.com/), but found nothing on GooXX either.
What you are describing is a Jenkins feature. Jenkins launches job as non-interactive mode so you wouldn’t be able to take parameter from ansible playbook while the job is executing.
You can however move the required parameter to Jenkins job for user input and then pass to ansible. For example, in case of jenkins pipeline parameters block can be used. These parameters then can be passed to ansible via --extra-vars and/or extras option of ansible plugin.

Jenkins Job DSL Plugin - Reading in External File

I'm having trouble with the Jenkins Job DSL Plugin. I can create the pipeline job via the plugin casc script, which is great. However, now I am trying to read in a csv file to autopopulate some parameters for it. readFileFromWorkspace is failing and readFile isn't working either. I'm trying like this: def file = readFileFromWorkspace("${ENV_VAR}file.csv") (which gives us /usr/share/jenkins/casc-configs/file.csv)
I verified file is present on the Jenkins Master at the above path (which is a Docker Container - running on Kubernetes). I can shell to the container and see it there.
Does anyone have experience with an effort similar to this? The errors I get are 'No signature of method: script.readFile() is applicable for argument types (org.codehaus.groovy.runetime.GStringImpl) values :( /file/location/here) <--- which I verified the file is present at this value on the Jenkins master container.
The readFileFromWorkspace error is:
java.lang.NullPointerException at javaposse.jobdsl.plugin.JenkinsJobManagement.locateValidFileInWorkspace(JenkinsJobManagement.java:428)

How to configure Jenkins to report major errors to the administrator?

e.g. I have the following errors in jenkins.err.log. How can I make Jenkins email this type of errors to me?
caused by: com.microsoft.tfs.core.ws.runtime.exceptions.UnauthorizedException: Authorization failure connecting to 'http://vstsprodapp:8080/Services/v1.0/Registration.asmx' (authenticating as domain\user)
This isn't a feature that's built into Jenkins.
You could use whatever system you use for monitoring your servers, and check the logs on the Jenkins server for error messages.
There is also an idea suggested on the Jenkins wiki, which allows you to use a Groovy hook script to add a further Java logging handler to Jenkins. But again, even if you do this, you would still have to implement a custom solution to send notifications based on the log's contents.
From https://wiki.jenkins-ci.org/display/JENKINS/Logging:
Put the following Groovy script into a file called $JENKINS_HOME/init.groovy.d/extra_logging.groovy:
import java.util.logging.ConsoleHandler
import java.util.logging.LogManager
def logger = LogManager.getLogManager().getLogger("hudson.WebAppMain")
logger.addHandler (new ConsoleHandler())
This will just copy all log records generated by Jenkins and any plugins to the console.

How to use Job Import Plugin in Jenkins?

I am using one Jenkins setup/instance to run the smoke tests (i.e using this Jenkins for QA only). Now I have to use another Jenkins job url in my first instance. The purpose is after successful code staging (on Dev Jenkins) it should automatically trigger the smoke tests (on QA Jenkins).
I know that Job import plugin can be used to achieve this but I am not sure as in where exactly to configure it. Googled it as well but unable to find anything.
Any help on this would be really appreciated.
Thanks in advance !
Just import the Job Import plugin, restart Jenkins and then access the plugin on your browser using the URL:
< Jenkins URL >/job-import
For Ex: http://localhost:8080/jenkins/job-import
If you get an error page here, cross-check whether plugin installation was successful or not. This won't work until all the dependent plugins are get installed successfully.
If you have a HTTP access to the DEV machine, maybe you can use the URL trigger plugin:
https://wiki.jenkins-ci.org/display/JENKINS/URLTrigger+Plugin
And trigger the last successful build number URL:
http://YOUR_JENKINS_SERVER/job/YOUR_JOB/lastSuccessfulBuild/buildNumber
If you don't have any access between your QA and DEV machines, it will be hard to trigger a job ;)
Download Jenkins JAR file
Go to location where JAR is located and enter following command
java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/ -auth admin:password create-job UploadToReleases < C:\Users\admin\UploadtoReleases.xml
create-job is command to import a job.
create-job always required name of jenkins job followed by < filename

postbuild UIAutomation script not running in jenkins

I am trying to do End-to-End automation for an iOS project. My aim is to automate the continuous integration process with attaching UIAutomation scripts as post build action.
So from the time when a user do check his code in SVN and till we get test result of automation, everything will be automated.
Jenkins is installed on my local machine and running on localhost.
Now I have automated build process through jenkins and at other end I have my shell script ready which will run UIAutomation java scripts on build output.
When I use my shell script as post build action then I get error in running instrument command(written inside shell script) but if I run this script manually through terminal then it works fine.
instruments[64703:60f] -[NSAlert alertWithError:] called with nil NSError. A generic error message will be displayed, but the user deserves better.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. Mon Feb 6 13:15:20 inpunml310743 instruments[64703] <Error>: kCGErrorFailure: Set a breakpoint # CGErrorBreakpoint() to catch errors as they are logged. 2012-02-06 13:15:20.179 instruments[64703:60f] Recording cancelled : At least one target failed to launch; aborting run Instruments Trace Error : Failed to start trace. Build step 'Execute shell' marked build as failure Finished: FAILURE
then i tried this command with sudo then I got following error
sudo: no tty present and no askpass program specified
Please let me know how can I run these commands successful, only this step is left in my task.
Jenkins by default installs as a LaunchDaemon, which means it has insufficient permissions to launch WindowsServer.
You’ll need to configure it as a LaunchAgent:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist
Then login as Jenkins and keep a session open.
If you don't know the Jenkins password you can change it with:
sudo passwd jenkins
Jenkins is running as a daemon and is therefore not allowed to connect to the window server. More info here http://developer.apple.com/library/mac/#technotes/tn2083/_index.html.
Sorry - not got time to put a complete answer now, will update later....
This is possible if you run jenkins as a user app rather than as a deamon -- this might come in handy (https://github.com/stisti/jenkins-app) I haven't tried it but looks like it should work -- I went down another route setting up an always logged in user, that ran jenkins from a login script, it did mean I had to re-install jenkins but managed to get it up and running... word of warning from someone thats been through it, are you using instruments for automated testing? If so, you'll need to do some transformation on the output so it displays in Jenkins.
We have a Jenkins Linux instance that builds to a Mac slave over SSH. One interesting requirement that we noticed with this error is that the build user on the slave must be logged into the console in order for everything to work correctly.
In addition, we had to make the build user an Admin, developer permissions were insufficient.
See more info here:
UIAutomation : Failed to authorize rights with status: -60007

Resources