Grunt Shell + Heroku Push = No stdout - heroku

Using Grunt to build, add, commit and push my code up to Heroku.
Build, add and commit are working great.
When I specify to "git push heroku master" in grunt shell I get no stdout while the process runs.
Here is the code in Grunt.js:
'git-push': {
command: 'git push heroku master',
options: {
failOnError: true,
stdout: true,
execOptions: { cwd: '../deploy'}
}
}
But I am only seeing the following when the process runs:
$ grunt push
Running "shell:git-push" (shell) task
Done, without errors.
I would like to see the output of the push while the push is in process.
Anyway to do this?
Update: Full grunt shell script
shell: {
'git-add': {
command: 'git --no-pager add .',
options: {
stdout: true,
execOptions: { cwd: '../deploy'}
}
},
'git-commit': {
command: 'git --no-pager commit -m "update"',
options: {
stdout: true,
execOptions: { cwd: '../deploy'}
}
},
'git-push': {
command: 'git --no-pager push heroku master',
options: {
failOnError: true,
stdout: true,
execOptions: { cwd: '../deploy'}
}
}
}
Final Grunt Shell (working):
shell: {
'git-add': {
command: 'git --no-pager add .',
options: {
stdout: true,
stderr: true,
execOptions: { cwd: '../deploy'}
}
},
'git-commit': {
command: 'git --no-pager commit -m "update"',
options: {
stdout: true,
stderr: true,
execOptions: { cwd: '../deploy'}
}
},
'git-push': {
command: 'git --no-pager push heroku master',
options: {
failOnError: true,
stdout: true,
stderr: true,
execOptions: { cwd: '../deploy'}
}
}
}

See:
How to make git diff write to stdout?
Adding --no-pager as an option, gives output.
git --no-pager <subcommand> <options>
Also, certain git commands write to stderr,as discussed here:
http://git.661346.n2.nabble.com/git-push-output-goes-into-stderr-td6758028.html
By including the flag and capturing stderr in the grunt task I was able to get output for the last part of the heroku push process (but not the part where the upload is tracked):
Fetching repository, done.
-----> Node.js app detected
PRO TIP: Specify a node version in package.json
See https://devcenter.heroku.com/articles/nodejs-support

Related

Permission denied error while running Cypress UI automation scripts with Jenkins in docker linux containers

We have a UI automation script created using Cypress/JavaScript. Scripts run perfectly fine on the local machine. We created a Jenkins job and are trying to run scripts in linux docker container. Pls see below Jenkinsfile for same.
#Library('jenkins-shared-libraries#v2') _
pipeline {
agent {
kubernetes {
yaml podYamlLinux(
customContainerYamls: [
'''
- name: nodeimg
image: node
options: --user 1001
imagePullPolicy: Always
resources:
requests:
memory: "100Mi"
cpu: "100m"
limits:
memory: "1Gi"
cpu: "500m"
tty: true
command:
- cat
securityContext:
privileged: true
'''
]
)
}}
stages {
// Install and verify Cypress
stage('installation') {
steps {
container('nodeimg') {
sh 'npm i'
sh 'npm install cypress --save-dev'
}
}
}
stage('Cypress Test') {
steps {
echo "Running Tests"
container('nodeimg') {
sh 'npm run cypressVerify'
}
}
}
}
post {
// shutdown the server running in the background
always {
echo 'Stopping local server'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true,
reportDir: 'cypress/report', reportFiles: 'index.html', reportName: 'HTML
Report', reportTitles: ''])
}
}
}
I have attached pic of package.json file as well.
I have tried different configurations to resolve this but currently getting error message "/tmp/cypressVerify-b91242e3.sh: 1: cypress: Permission denied script returned exit code 126".
It would be great if community help me resolve this.

report folder does not exist error with htmlpublisher

I am trying to write a jenkins pipeline script for one of my playwright test. Below is one simple code which i have done so far.
pipeline {
agent any
stages {
stage('Run Playwright Test') {
steps {
runTest()
}
}
stage('Publish Report'){
steps {
script {
sh 'ls -lrta'
//print REPORT_FILES
}
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
//reportDir: '.',
reportDir : "./TestReport2",
reportFiles: 'index.html',
reportName: "Html Reports",
reportTitles: 'Report title'
])
}
}
}
}
def runTest() {
node('MYNODE') {
docker.image('image details').inside('--user root'){
git branch: 'mybranchName',credentialsId: 'ID, url: 'url'
catchError() {
sh """
cd WebTests
npm install
npx playwright test --project=CHROME_TEST --grep #hello
"""
}
sh "cp -R WebTests/TestReport TestReport2"
sh 'cd TestReport2; ls -lrta'
}
When I use the above code, the test executed successfully however i am seeing an error while trying to publish the report.
Below is the error :
Specified HTML directory '/bld/workspace//TestReport2' does not exist.
observation: when i put a ls -ltr after the runTest code i could not see the TestReport2 folder even if it was copied successfully.
Another thing i tried is when i put the code to publish the HTML as part of the runTest() it worked fine and i am able to see the reports generated. Something is going on with the TestReport2 folder when the block of code for runTest() is completed.
Does anyone have an eye on what is the root cause. Any suggestion will be appreciated

GIT push step failing in Jenkins

Below code was working fine and all of the sudden it broken. I am using windows box.
stage('Push')
{
withCredentials([usernamePassword(credentialsId: 'gitlogin', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh('git push --tags origin $BRANCH_NAME')
}
if ("${BRANCH_NAME}"=="develop" || ("${BRANCH_NAME}".startsWith("release")))
{
sshagent (credentials: ['GitSSHLOGIN']) {
sh("git tag -a PBCS_${BRANCH_NAME}_${ReleaseNumber}_${BUILD_NUMBER} -m 'Tag the build ${BRANCH_NAME}_${ReleaseNumber}_${BUILD_NUMBER}'")
sh('git push --tags origin $BRANCH_NAME')
}
}
}
Below is the error we are getting.
+ git push --tags origin release/21.04
Could not create directory '/c/Jenkins/jobs/branches/release-21-04.3rkqb4/workspace/nullnull/.ssh'.
ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Jenkins Pipeline - Parallel steps skip latest Git commits and Ruby's Bundler commands pause unexpectedly

I am writing my first declarative pipeline and I would like to run the Git Checkout and Bundler stage in parallel. When the steps from these stages are executed in parallel, I experience odd behaviors. For example:
I want to check out the latest copy of a PR to test. In the parallel step, the check out will fail to get the latest commit and will fetch an older commit as the HEAD. I have verified that the BitBucket server has newer commits than the one checked out.
Figured this out: In Bitbucket server, you need to manually access the PR page and refresh the "commit cache". This way the latest commits are served to Jenkins.
Source: https://community.atlassian.com/t5/Bitbucket-questions/Change-pull-request-refs-after-Commit-instead-of-after-Approval/qaq-p/194702
I want to run Ruby's Bundler gem (bundle install & update) in 4 different repositories at the same time. When the parallel step executes, it would unexpectedly pause/hang on bundle install in the cr_dbvals repos and not print anything to the console. Have to abort the build at this point.
Agents OS: Windows 10 x64
Running these steps sequentially yields the expected results and everything works fine. Not sure what I am missing in my script here:
pipeline {
agent {
node {
label "${env.executor_label}"
}
}
stages {
stage('Set Build Name') {
steps {
script {
currentBuild.displayName = "#${env.BUILD_NUMBER} - ${env.app_node} - ${env.browser}#${env.NODE_NAME}"
}
}
} // stage('Set Build Name')
stage('Git Checkout') {
steps {
parallel(
"Git Cucumber-Watir": {
dir('cucumber-watir') {
git(url: 'http://git-repo-url/cucumber-watir.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.cucumber_watir_branch}")
}
},
"Git CrModels": {
dir('cr_models') {
git(url: 'http://git-repo-url/cr_models.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.cr_models_branch}")
}
},
"Git CaModels": {
dir('ca_models') {
git(url: 'http://git-repo-url/ca_models.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.ca_models_branch}")
}
},
"Git CrDbVal": {
dir('cr_dbvals') {
git(url: 'http://git-repo-url/cr_dbvals.git', branch: 'master', changelog: true)
bat(script: 'git config --add remote.origin.fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*')
bat(script: 'git fetch origin -p')
bat(script: "git checkout ${env.cr_dbvals_branch}")
}
}
) // parallel
} // steps
} // stage('Git Checkout')
stage('Bundler') {
steps {
parallel(
"Bundle Cucumber-Watir": {
dir('cucumber-watir') {
bat(script: "bundle install")
bat(script: "bundle update")
}
},
"Bundle CrModels": {
dir('cr_models') {
bat(script: "bundle install")
bat(script: "bundle update")
}
},
"Bundle CaModels": {
dir('ca_models') {
bat(script: "bundle install")
bat(script: "bundle update")
}
},
"Bundle CrDbVal": {
dir('cr_dbvals') {
bat(script: "bundle install")
bat(script: "bundle update")
}
}
) // parallel
} // steps
} // stage('Bundler')
stage('Execute Test(s)') {
steps {
dir(path: 'cucumber-watir') {
bat 'set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1'
bat(script: 'cucumber -t %tags% -f json -o cucumber.json -f pretty --expand')
}
} // steps
} // stage('Execute Test(s)')
} // stages
post {
always {
dir(path: 'cucumber-watir') {
cucumber 'cucumber.json' // Build Cucumber Report
}
deleteDir() // Cleanup
} // always
} // post
} // pipeline

How to stop nodemon debugger on production

This is my grunt file: (the relevant portion)
nodemon: {
dev: {
script: 'server.js',
options: {
nodeArgs: ['--debug'],
ext: 'js,html',
watch: watchFiles.serverViews.concat(watchFiles.serverJS)
}
}
},
'node-inspector': {
custom: {
options: {
'web-port': 1337,
'web-host': 'localhost',
'debug-port': 5858,
'save-live-edit': true,
'no-preload': true,
'stack-trace-limit': 50,
'hidden': []
}
}
},
concurrent: {
default: ['nodemon', 'watch'],
debug: ['nodemon', 'watch', 'node-inspector'],
options: {
logConcurrentOutput: true
}
},
});
// Load NPM tasks
require('load-grunt-tasks')(grunt);
// Default task(s).
grunt.registerTask('default', ['lint', 'concurrent:default']);
// Debug task.
grunt.registerTask('debug', ['lint', 'concurrent:debug']);
// Lint task(s).
//grunt.registerTask('lint', ['jshint', 'csslint']);
grunt.registerTask('lint', ['jshint']);
On my server, when i write this command:
NODE ENV=production PORT=80 grunt --force
Im having this promped in my console:
I want no debugger in production, what needs to change?
I tried to remove the nodemon --debug option but with no success,
also i tried to change the debug port to another one in node-inspector, but i dont really initiate the node-inspector in the command above, and what tells him to do the nodemon-dev portion at all?

Resources