postbuild UIAutomation script not running in jenkins - ios

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

Related

Failed to setup GlobalToolConfiguration In Jenkins - Http Status 403-Forbidden

My Jenkins is running in an azure app service as a java web application. as soon the app service started jenkins started & running successfully.
Im accessing Jenkins UI using the url https://app-service-url/jenkins
I logged into jenkins with initial admin password The next step is to choose install suggested plugin & select plugins to install
upon clicking any of this options im getting "Error ocurred during installation".
However After few retries plugins are installed but for all further operation I do it is giving Http 403- Forbidden.
I tried to add Jdk in Global Tool Configuration before adding values it is throwing error and even I save it ends with 403-forbidden result.
I could not able to do anything in jenkins I failed to install new plugins,setup basic configuration,run commands in jenkins script console etc.
In all the cases periodically receiving Http 403-Forbidden.
In jenkins system log I found the messages.
Solutions Tried:
Tried to enable "Enable proxy compatibility" in GlobalSecurity - but 403-Forbidden
Added hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION = true in my app service Configuration(Similar to setting the Env Variable)
Created init.groovy script in JENKINS_HOME and added below commands
def instance = Jenkins.instance
instance.setCrumbIssuer(null)
Tried to install strict-crumb-issuer jenkins plugin but failed to install
Note: I tried latest jenkins version 2.375 as well as the downgraded version(2.361.2,2.332 etc).
looking for a solution to fix this no valid crumb Http 403- forbidden.

Check console logs (and stop build if needed)

We are using Jenkins (on Linux) to manage our builds.
I want to monitor the console output of all currently running jobs and abort the build if any matched pattern / exception / error is found.
For example, if the console output has IndentationError(when the job is running), I would like to automatically stop the build.
Please let me know if there are any plugins or solutions for this?
Thank you.
Jenkins will stop any build when a tool returns a non-zero exit code. If you want your build to exit on the first error, then you should configure the tools you are calling from jenkins to exit as soon as an error occurs (through command line flags etc.). Parsing console output for an error is a hacky solution at best.

how to deploy Drupal with Jenkins only if the tests are successful

I have some doubts about the correct configuration of Jenkins to ensure the continuous integration of a Drupal project but I arrive at some contradictions.
Let me explain: the deployment, after all, consists in executing:
cd / path / to / web / root
pull from git
drush config:import
drush cache:rebuild
The tests are launched with the command
../vendor/bin/phpunit --verbose --log-junit ../tests_output/phpunit.xml -c ../phpunit.xml
The contradiction is that I do not understand when to run the tests.
Before the pull does not make sense because the last changes are missing, after the pull if any test goes wrong I should be able to restore the situation before the pull (but I'm not sure it's a safe action).
I'm trying to run the tests directly in the workspace of jenkins and to do this I also created a separate database, but at the moment I get the error:
Drupal\Tests\field_example\Functional\TextWidgetTest::testSingleValueField
Behat\Mink\Exception\ElementNotFoundException: Button with id|name|label|value "Log in" not found
What could be the best strategy to follow?
So, your order seems ok - pull first then run tests.
However, you can have 2 Jenkins jobs. First runs, your tasks. 2nd runs ONLY if your first job completes without failure.
There are ways to get exit status from scripts - see following plugins/notes about that.
How to mark Jenkins builds as SUCCESS only on specific error exit values (other than 0)?
How to mark a build unstable in Jenkins when running shell scripts

how I can change permission for a folder in jenkins?

I have jenkins working in local server on my mac and for a job, I need to run a script shell witch it need to read a json file. I tryied to put it in workflow-lib file. But when I run the job for testing, the script return an error witch says :
/Users/****/.jenkins/workflow-libs/testCollections: Permission denied
Build step 'Run a shell script' marked build as failure
Finished: FAILURE
So I know that the script can read the json file but I don't know how I can give it this permission.
thank you for helping
Please follow this command to give the permissions.
sudo chown -R <jenkins user>:<jenkins group> /jenkins_root_path
here <jenkins user> and jenkins group is the user and group which you are running jenkins under.
If the jenkins user is a member in the sudoers list:
sudo rm -rf /Users/****/.jenkins/workflow-libs/testCollections
But this can be dangerous.
I would highly suggest you run the Jenkins process as the jenkins user/group and not muck around in there as your own user account.
This will ensure your file permissions are proper and that the jenkins process only has access to the areas it needs as well as letting you spin up new slaves without worrying about permissions and custom settings.
You can always use sudo to become the 'jenkins' user to work with the files.

Jenkins logs for a perl build file

Today I started working with jenkins and I successfully added my projects to jenkins and it says all works fine . one of the build takes more than 5 hours but didn't finish either so aborted it(while manual build takes less than 1 hour).. and while i tried to check with the log the log was not detailed. so i tried to get the logs of the perl script by running it as a shell command
usr/local/bin/perl perlscript.pl>logfile.txt
there was no log written and there was no evidence of the build triggered either cases.i'm not aware of what the problem is as both the perlscript(works fine while manually triggered) and jenkins are working properly except this project. I would like to have your help.thanks in advance
A few things you should understand about Jenkins:
Jenkins shows STDOUT as the log of the Job,
so if you redirect it to a file - nothing will be shown in the log.
Depending on how you have set it up, Jenkins may run as its own user,
which may change the behavior of your scripts.
You can confirm this by echo-ing the username at the beginning of your Execute Shell block,
for example:
echo $USER
Each Jenkins-Job is run from its own workspace -
you can confirm that location by simply printing the current working directory
at the beginning of your Execute Shell block, for example:
echo my current directory is
pwd

Resources