Send iOS Push Notifications with Node.js on Openshift - ios

I'm developing a website , that should send push notifications to iOS devices. I followed this tutorial to send notifications. On my localhost apnagent works fine, but when I git push it to my Openshift cloud I get the following errors in the terminal:
remote: Waiting for application port (8080) become available ...
remote: Application 'apnagent' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 55c3344c89f5cf720xxxxxxx (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/55c3344c89f5cf720xxxxxxx/nodejs
remote: #<IO:0x00000000f1c278>
remote: #<IO:0x00000000f1c200>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed
To ssh://55c3344c89f5cf720xxxxxxx#apnagent-xxxxxxx.rhcloud.com/~/git/apnagent.git/
bbcf2a3..87exxxx master -> master
My package.json looks like this:
{
"private": true,
"name": "apnagent",
"version": "0.0.0",
"dependencies": {
"apnagent": "1.0.x"
},
"engines": {
"node": ">=0.10.22",
"npm": ">=1.3.14"
},
"scripts": {
"start": "node agent/_header.js"
},
"main": "agent/_header.js"
}
I think i should use somehow process.env.OPENSHIFT_NODEJS_PORT as port on the server, or something like this. I'm sure, I've done some configuration mistake since on my local machine everything works fine.

Did you check the logs on the server? SSH into your app and use
less app-root/logs/nodejs.log
and press shift+g to view the recent console outputs for the server. I had a few syntax errors in my scripts and they were causing a similar error.
If that doesn't help, could you post your server script?

Related

Getting "Unable to establish one or more of the specified browser connections" when running testcafe and browserstack

We are creatign a POC for running testcafe and browserstack in our jenkins.
the jenkins file starts a node instance, starts upp browserstack local, runs the tests and then closes browserstack local.
The browserstack local log indicates that it works ok, but the console states "ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure."
i can se in browserstack dashboard that the browser is started and is given an URL (example: http://127.0.0.1:44138/browser/connect/bl5rZIw) but the browser gives a "unable to connect to the page"
if i change from browserstack to a local chrome everything works. and if i run things on my local mashine it works (with browserstack.)
the networkpepole cant find any relevant blocks in the firewall. only calls to githubb.
(185.199.110.153, TCP/443,140.82.121.3, TCP/443 - BLOCKERAT,140.82.121.5, TCP/443 - BLOCKERAT, 140.82.121.6, TCP/443 - BLOCKERAT)
any ideas on what is missing or how to digg into this problem.
relevant files
------------jenkins.openshift--------------------------
node('nodejs-14') {
withRepository {
stage('Install dependencies') {
withProxy {
sh 'npm install'
}
}
stage('Test') {
withProxy {
withEnv([
"BROWSERSTACK_LOCAL_IDENTIFIER=${env.BUILD_TAG}",
"BROWSERSTACK_USERNAME=<secret :)>",
"BROWSERSTACK_ACCESS_KEY=<secret :)>"
]) {
try {
sh "src/support/linux/BrowserStackLocal --key ${env.BROWSERSTACK_ACCESS_KEY} --local-identifier ${env.BUILD_TAG} --daemon start --force-local --proxy-host rbp-openshift-registry-001.wa.loc --proxy-port 3128 --local-proxy-host <secter :)> --local-proxy-port 3128 --verbose 2 --log-file ${env.WORKSPACE}/browserstack.log"
sh "npm test"
} finally {
sh "src/support/linux/BrowserStackLocal --key ${env.BROWSERSTACK_ACCESS_KEY} --local-identifier ${env.BUILD_TAG} --daemon stop"
archiveArtifacts artifacts: 'browserstack.log'
}
}
}
}
}
}
--------------------package.json--------------------------------
{
"name": "testcafe-poc",
"version": "1.0.0",
"description": "A Proof of Concept project and template for running testcafe and browserstack. ",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/testcafe 'browserstack:chrome#93.0:Windows 10' --hostname 127.0.0.1 --proxy rbp-openshift-registry-001.wa.loc:3128 ./src/tests/test1.js"
},
"repository": {
"type": "git",
"url": "ssh://git#code.resurs.loc:7999/test/testcafe-poc.git"
},
"author": "",
"license": "ISC",
"devDependencies": {
"testcafe": "1.9.4",
"testcafe-browser-provider-browserstack": "1.13.1"
},
"dependencies": {}
}
You mentioned that everything works fine locally without Jenkins. This means that there is no error in TestCafe of BrowserStack.
Probably, the issue is in your BrowserStack Local configuration. The testcafe-browser-provider-browserstack already has its own BrowserStackLocal instance, so it's not necessary to use BrowserStackLocal from src/support/linux/BrowserStackLocal.
Please refer to the following issue to see how to setup BrowserStack proxy settings: https://github.com/DevExpress/testcafe-browser-provider-browserstack#browserstack-proxy-options.
The solution was simple and ridiculous.
We used a % in our sting for --local-identifier and that makes the BrowserStack local fail to connect.
But it does not tell you this in the logs or documentation.
So the solution is: don't use special characters in the --local-identifier.

How can I inject environment variables during the build process in Github CI/CD?

I am creating a blogsite with Gatsby and Contentful for learning purposes. I want to deploy my site to surge using Github actions. I am using gatsby-source-contentful plugin to get my content from Contentful at build time. The plugin requires spaceId and accessToken to access my Contenful space. During development at my local machine, I am providing these values to the plugin using environment variables saved in a .env file.
However, during the build process in Github actions, I am getting this error:
success open and validate gatsby-configs - 2.325s
error Invalid plugin options for "gatsby-source-contentful":
- "accessToken" is required
- "spaceId" is required
not finished load plugins - 1.002s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-contentful-blogsite#0.1.0 build: `tsc && gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-contentful-blogsite#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-02-18T17_53_11_281Z-debug.log
Error: Process completed with exit code 1.
Is there a way to tell Github actions about these environment variables (spaceId and accessToken) so that the gatsby-source-contentful plugin can be configured successfully?
Contentful DevRel here. 👋
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `your_space_id`,
// Learn about environment variables: https://gatsby.dev/env-vars
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
},
},
],
}
In your gatsby config you can specify your environment variable such as above. Then in your GitHub repo you can define a secret and expose it as environment variable. You can find more information in the Github actions docs. Once you exposed the environment variable via the secret to the action, it should work fine.

How to provide a valid crumb in ansible jenkins_script module

I am using Ansible to check the status of several jenkins servers. The playbook that I have created checks the disk space, uptime, and jenkins version perfectly fine. However, I tried to add a task that prints out a list of the installed jenkins plugins for each server by using the jenkins_Script module and keep receiving a '403' error message.
Playbook:
- name: Obtaining a list of Jenkins Plugins
jenkins_script:
script: 'println(Jenkins.instance.pluginManager.plugins)'
url: 'http://server.com:8080/'
user: '*****'
password: '*****'
Output:
fatal: [server]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"args": null,
"force_basic_auth": true,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"script": "println(Jenkins.instance.pluginManager.plugins)",
"url": "http://server.com:8080/",
"url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"validate_certs": true
}
},
"msg": "HTTP error 403 HTTP Error 403: No valid crumb was included in the request"
}
-- I believe I have narrowed down the issue - It looks like I wasn't providing a crumb. I have since generated the crumb, but there is no 'crumb' arguement for the jenkins_script module. Does anyone know how to successfully provide a crumb?
Will gladly clarify anything stated above if needed, and any assistance is greatly appreciated.
https://github.com/ansible/ansible/pull/20207
-- if you're on ansible 2.3 the changes have already been committed all you have to do is make sure 'cross site request forgery' is enabled on the jenkins servers. (Manage jenkins > Configure Global security)

Bower install fails to find satisfying version, although there is a matching tag on GitHub

I am having problems installing bower dependencies on a Windows installation. Installation fails for me on Windows 7 x64, with git 2.6.4.windows.1, node v5.4.1, npm 3.3.12, bower 1.7.2.
It works for a colleague on OSX (git 2.5.4, node v4.1.1, npm 2.14.4, bower 1.5.3) and for a colleague on Windows 10 (git 2.5.0.windows.1, node v4.2.2, npm 2.14.7, bower 1.3.11).
The error message I am getting basically tells mit that bower-angular-translate does not have a version tag that satisfies 2.8.1, but the GitHub repository does have a version 2.8.1.
The failing packages are angular-ui-router, angular-local-storage and angular-translate.
I tried downgrading node to 0.10.x and 4.x.x and reinstalling bower, both did not work.
If anyone has experienced the same error message behavior with bower (on windows?) and has successfully solved it, any pointers would be greatly appreciated.
The error message after running bower install:
bower angular-translate#~2.8.1 ENORESTARGET No tag found that was able to satisfy ~2.8.1
Additional error details:
No versions found in git://github.com/PascalPrecht/bower-angular-translate.git
My bower.json:
{
"name": "My App Name",
"version": "0.0.1",
"dependencies": {
"angular": "1.4.7",
"angular-animate": "1.4.7",
"angular-aria": "1.4.7",
"angular-cookies": "1.4.7",
"angular-resource": "1.4.7",
"angular-sanitize": "1.4.7",
"angular-material": "0.11.2",
"angular-ui-router": "0.2.5",
"angular-local-storage": "0.2.x",
"angular-translate": "~2.8.1"
}
}
Just in case, my package.json:
{
"author": "My Name",
"name": "My App Name",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"chai": "2.2.0",
"gulp": "3.9.x",
"gulp-angular-filesort": "1.1.1",
"gulp-bower-files": "0.1.x",
"gulp-clean": "0.2.x",
"gulp-debug": "2.1.x",
"gulp-concat": "2.2.x",
"gulp-filter": "1.0.x",
"gulp-inject": "0.4.x",
"gulp-less": "1.2.3",
"gulp-livereload": "1.3.x",
"gulp-tsc": "0.10.x",
"gulp-uglify": "1.2.x",
"gulp-util": "2.2.x",
"gulp-watch": "0.6.x",
"karma-coverage": "~0.2.4",
"karma-mocha": "~0.1.6",
"karma-phantomjs-launcher": "^0.1.4",
"karma-sinon-chai": "~0.2.0",
"merge-stream": "0.1.x",
"mocha": "~1.20.1",
"phantomjs": "^1.9.17",
"q": "1.0.x",
"run-sequence": "0.3.x"
}
}
GitHub revoked my SSH keys, causing git clone to fail.
Since cloning repositories via git clone --branch <tagname> https://<repo> at the "missing" tag worked, I understood from the error message that bower was not able to find the tag.
Both my bash from msys-git and my cmd.exe were set up to use Putty's plink.exe, while bower was trying to connect via OpenSSH. Putty was set up with the correct private key, OpenSSH was not.
The culprit here was GitHub, which removed my SSH public key from my profile, making git clone via SSH (which is the default for bower install) fail with a Permission denied (publickey).
The combination of GitHub not sending me a notification email about this and the bower error message describing an entirely different error made error-tracing this a nightmare.
Kudos go to Andra for the comment to use git config --global url."https://".insteadOf git://. While not suitable as a permanent solution (my company's git server enforces SSH, since it is superior to a simple user-password combination), it helped limit the problem to the SSH access.
Try to change the git protocol from git to https by executing:
git config --global url."https://".insteadOf git://

Selenium failing with EOFile error with chromedriver on linux

I have an automated build machine running cucumber tests on an EC2 instance. I am using:
capybara (1.1.4)
selenium-webdriver (2.31.0)
chromedriver (25.0.1364.172-187217)
The tests are run headless using Xvfb X11 Server (1.7.7-29.10.amzn1) This setup has been working fine for months, but last week stopped working on these machines.
The error I am getting is:
(::) failed steps (::)
end of file reached (EOFError)
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:135:in `read_nonblock'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:135:in `rbuf_fill'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1177:in `request'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:627:in `start'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1168:in `request'
./features/step_definitions/web_steps.rb:49:in `/^(?:|I )go to (.+)$/'
My best guess is the problem is due to upgrades to the selenium or chromedriver libraries in the past month as these are updated whenever a build instance is started.
I have checked the chromedriver logs but they do not appear to offer anything helpful:
0.000][INFO]: ChromeDriver 23.0.1240.0 /mnt/bamboo-ebs/bin/chromedriver/chromedriver
[0.259][FINE]: Initializing session with capabilities {
"browserName": "chrome",
"chrome.detach": true,
"chromeOptions": {
"detach": true
},
"cssSelectorsEnabled": true,
"javascriptEnabled": true,
"nativeEvents": false,
"platform": "ANY",
"rotatable": false,
"takesScreenshot": false,
"version": ""
}
[0.259][INFO]: Using named testing interface
[0.676][INFO]: Connected to Chrome successfully. Version: 25.0.1364.172
[0.693][FINE]: Command received (/session/132be881788b1e7a6c878f4c45935176)
[0.693][FINE]: Command finished (/session/132be881788b1e7a6c878f4c45935176) with response {
"sessionId": "132be881788b1e7a6c878f4c45935176",
"status": 0,
"value": {
"acceptSslCerts": false,
"applicationCacheEnabled": false,
"browserConnectionEnabled": false,
"browserName": "chrome",
"chrome.chromedriverVersion": "23.0.1240.0",
"chrome.nativeEvents": false,
"cssSelectorsEnabled": true,
"databaseEnabled": false,
"handlesAlerts": true,
"javascriptEnabled": true,
"locationContextEnabled": false,
"nativeEvents": true,
"platform": "linux",
"rotatable": false,
"takesScreenshot": true,
"version": "25.0.1364.172",
"webStorageEnabled": true
}
}
[0.695][FINE]: Command received (/session/132be881788b1e7a6c878f4c45935176/url) with params {
"url": "http://127.0.0.1:31337/"
}
[0.695][FINER]: Waiting for all views to stop loading...
[0.696][FINER]: Done waiting for all views to stop loading
[0.716][FINER]: Waiting for all views to stop loading...
All tests work successfully on my development machine (Mac OSX Mountain Lion) with chromedriver (26.0.1383.0). I have tried to downgrade my chromedriver to match the version on my build machine, but found I could not do this.
I have managed to get the tests to run using firefox, but this is not a long term solution for us.
Any help would be much appreciated.

Resources