Bitrise x Danger : bundle install, Could not locate Gemfile in "Do anything with Script step" - github

I'm new to CI, bitrise.
I've connected bitrise, project and Github and succeeded vanilla build.
Now I'm trying to show Auto PR comments on Github by using Danger connecting bitrise.
However, after pushing commits and making a pull request, the build was failed with this error on "Do anything with Script step" phase on bitrise.
What does "Could not locate Gemfile" mean in this case?
I have already added gemfile in local by these commands,
// create gemfile on the project directory
$ bundler init
// add danger in gemfile
gem "danger"
// install
$ bundle install
$ bundle exec danger init
And I've done
adding DANGER_GITHUB_API_TOKEN and github Access token in Env vars in bitrise
adding scripts in Do anything with Script step
This is my script.
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
# these 2 lines are what I added
bundle install
bundle exec danger
# write your script here
echo "Hello World!"
# or run a script from your repository, like:
# bash ./path/to/script.sh
# not just bash, e.g.:
# ruby ./path/to/script.rb
Is something missing to make Danger work in Github?
I have no idea what's going on here and I don't know even where I need to check.
If you have any ideas, please help me.
Feel free to ask me if you need more info to solve this.
Thanks.

This was happening to me because I was executing the Danger script before the Git Clone Repository step in my workflow.. It can't find the Gemfile because it's not in the correct directory; $BITRISE_SOURCE_DIR is not set prior to the Git Clone Repository step.

Related

Amazon Sagemaker Failed: Please check if you have a directory that has same name as the git repo?

I was working in Sagemaker, and noticed that my notebook instance was behind my github repo as I had just pushed to it outside of working in Sagemaker. I couldn't seem to pull, so I deleted the directory within Jupyter and git cloned my updated repo. It worked fine, but once I was done working I haven't since been able to reinitialize the notebook. Sagemaker simpy says
Failure reason
Please check if you have a directory that has same name as the git repo.
I cloned from the same repo, so I don't imagine that the directory name changed. Maybe the directory is in the wrong place? Either way, how do I go in and change things if I can't open the notebook? Not sure what to do about this.
Do you have a lifecycle configuration (LCC) script that clones the repository? I can't think of another reason why the notebook would fail to start (I assume what you meant by 'reinitialize'). If you do, remove the LCC script to start your notebook. Or you could add a condition to check for the folder and clone if it does not exist, something like -
if [ ! -d "$FOLDER" ] ; then
git -C /home/sagemaker-user clone $REPOSITORY_URL
# if you want to pull latest when restarting, uncomment lines below
# else
# cd "$FOLDER"
# git pull $REPOSITORY_URL
fi
I work at AWS and my opinions are my own.

Update submodules from remote via script during CI build

Issue: Update sub modules from remote via script during CI build
During a CI build script, I want the sub module to be updated to the latest as it is building. I am aware that the build process in VSTS takes care of checking out the sub modules, but they are checked out at the hash reference of whatever is there in the repository. I would like the process to update to the latest code.
The approach I used is as described below.
• I created a command line task in the build pipeline and added the script as below.
git -c http.https://bitbucket.org.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" submodule update --init --force --recursive --remote –merge
• I also checked out check Allow scripts to access OAuth Options in build definition and pass $(System.AccessToken) variable in the command above.
It seems to be the command line script is causing the problem and showing the following error message:
Could not read Username for https://bitbucket.org: terminal prompts disabled.
The build agent is able to execute other git commands such as pulling down the source, checkout the sub modules etc. Sub modules are accessed through https.
• How can I get the authorization done on my command line task??
• Is there any other approach to allow Git Sub modules to pull latest commits?
I cannot reproduce it with Bitbucket, but the way I run this from command line task against Azure DevOps Services Git Repo is this:
git config --unset-all http.{organization}#dev.azure.com.extraheader
git -c http.https://{organization}#dev.azure.com.extraheader="AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN" submodule update --init --force --recursive --remote
With Working Directory set to $(Build.SourcesDirectory) and "Allow scripts to access the OAuth token" checked.
My sample .gitmodules file looks like this (I obviously have multiple submodules)
[submodule {submodule}]
path = {submodule}
url = https://{organization}#dev.azure.com/{organization}/{project}/_git/{submodule}
branch = {branch}
I am not sure if that helps, but works in my scenario.

Push yeoman project to github

I try to work on a yeoman project with a team. After generating the angularjs code with > yo angular and pushed the folder to github
git add .
git push
git commit origin master
and when I clone the code from git github I have this error
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or
grunt hasn't been installed locally to your project. For more
information about installing and configuring grunt, please see the
Getting Started guide:
http://gruntjs.com/getting-started
so I deleted every thing from .gitignore and pushed everything again, I had this warning
The file will have its original line endings in your working
directory.
So I am quite sure it's not going to work and it's not the best way to do it. Can someone help me on how to upload the yeoman project ?
I think that angular generator for Yeoman already creates a package.json file with grunt defined as dependency along with all its task. So the correct way to compile a project after the clone is to install all npm dependencies locally using:
npm install
then run grunt to compile everything:
grunt
Of course you must have grunt-cli globally installed, which is used to run grunt locally. To install it you have to use the following command where -g defined the global install (default is local):
npm install -g grunt-cli
First of all, i think you have a typo in your question, you have mixed commit and push commands:
git add .
git commit -m 'commit message' // message is optional
git push origin master
First message appears because you don't have an installed Grunt. Install it in your working directory:
npm install grunt --save-dev
Starting with Grunt v0.4, you should never install Grunt itself
globally. For more information about why, please read this. Source: grunt-cli docs.
If it is alredy listed in the devDependencies, just run:
npm install
The second one is caused by line-endings. It is a good practice to include .gitattributes file in your repo. File's content should be:
* text=auto
Read about this file: docs. Or there is another method. It is described in this question.

Jekyll not processing plugins on server

Jekyll is processing my _plugins folder fine on my local machine (OS X 10.7.4, ruby 1.9.3), but it's not processing them on the server (Ubuntu 12.04, ruby 1.9.3). Both have the same version of Jekyll installed (0.11.2).
I'm trying to use the generate_sitemap plugin, here.
I'm deploying via git and the post-receive hook, which looks like this:
#!/bin/bash -l
GIT_REPO=/my_repo.git
TMP_GIT_CLONE=/my_temp_folder/
PUBLIC_WWW=/my_public_folder/
git clone $GIT_REPO $TMP_GIT_CLONE
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
I am seeing this error when I deploy:
remote: /home/ed/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
But, from what I've read, that's a Maruku warning and has nothing to do with the plugins.
Anybody have any ideas about what I can try to figure this out? I'm at a bit of a loss.
It's very hard to debug with Jekyll, but it's a great tool !!!
I assume you have more than one plugin in your _plugins folder.
So maybe one or some of your plugins , cause the problem.
If I'm right, you can do the following :
Kill your Jekyll
Create a backup of your plugins in another location (not in _plugins
folder).
Leave just one plugin in your _plugins folder and start Jekyll.
If it works , copy another plugin to the _plugins folder, until you
find the one which fails the Jekyll.
When you find it, you can add debug printouts to the problematic plugin (that's what I did).
Something like :
puts "before .... "
I have built the http://www.cloudifysource.org/ only with Jekyll and you can find and use lots of our useful examples in our GitHub repo : https://github.com/CloudifySource/cloudifysource.github.com
I had the same problem with Jekyll not loading plugins when called from the post-receive hook.
As is mentioned in the comments above, changing the current working directory to $TMP_GIT_CLONE does the trick.
You don't have to change anything in _config.yml.
#!/bin/bash -l
GIT_REPO=/my_repo.git
TMP_GIT_CLONE=/my_temp_folder/
PUBLIC_WWW=/my_public_folder/
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE # move to the temp dir
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd # move back to allow deletion
rm -Rf $TMP_GIT_CLONE
exit
This is a real head-scratcher seeing as executing the original post-receive hook manually as the git user works just fine... Anyway, Jekyll is now loading plugins on my server and hopefully making this a proper answer will help others to find this solution.
Lately, I start to build https://github.com/alswl/code-standards-jekyll with jekyll.
I write two plugins in _plugins, and I found it was hard to debug.
At first, I use puts "balabala" to debug, it seems work.But once I met problem that didn't generate anything in the _site folder, and there was no 'balabala' in the console, I was panic.
After I read the jekyll source, I try to set auto=false in _config.yml, running jekyll will produce some debug trace stack error. Thank godness.
So, ues auto=false will help you to debug plugins.

How to deploy jekyll on slicehost

I have jekyll blog up and running locally. I am not sure how to push the content to slicehost. They have an instruction page but I am not able to follow the instruction.
I have all my content on github. Just need to know how to make post-update hook work?
To deploy a generated Jekyll site, you just need to copy the contents of the local _site directory to the appropriate remote directory on your server (often public_html, but it depends on the server configuration).
Personally, I think the easiest way is to just use rsync, assuming you can use rsync with your server. Then it's as simple as executing the command
$ rsync -avz --delete _site/ user#host:/path/to/web/root
to deploy your site. For my Jekyll-based sites, I encapsulate this in a Rake task so I can just do
$ rake site:deploy
to copy the site to the server.
If you can't use rsync, you can always transfer the _site directory via FTP, which is also pretty easy to do (and with a bit of Ruby scripting, can be automated using Rake as well).
You can use Git, as noted in the Jekyll docs. You will have to have Git installed on your server, and access to using it. If that's the case, you have to create a bare Git repo on your server. In the bare repo, you then create a post-update hook to check out the latest copy of the site. You do this by creating a script at $BARE_REPO/hooks/post-update with contents like the following (as noted here):
#!/bin/sh
unset GIT_DIR && cd /path/to/web/root && git pull
You then clone the bare repository to your web root, like so:
$ cd /path/to/web/root
$ cd ..
$ rm -rf root
$ git clone /path/to/bare/repo.git root
As you can see, it's often easier to use rsync or FTP instead of Git.