Running origen-sdk commands in Bamboo - origen-sdk

Has anyone run Origen application commands in Bamboo? Something along the lines of:
git clone myapp.git
cd myapp
bundle install
origen p myflow.rb
I see that the lbin directory (where bundle lives) is ignored in the .gitignore yet shows up in the application. Having issues running the bundle install, saying it cannot find bundle.
thx

Origen needs to get first crack at running Bundler within a new workspace so that it can provide a default configuration, so the flow should be:
git clone myapp.git
cd myapp
origen -v # Just a throwaway invocation, lbin should be created by this
origen p myflow.rb
However, sometimes it can be hard to add ./lbin to the path in the Bamboo/CI environment like you can in your personal env, so quite often we run in CI like this:
git clone myapp.git
cd myapp
bundle install
bundle exec origen p myflow.rb
That's a more conventional/direct way of running with Bundler, but who wants to type bundle exec everytime, so it is better in a user env to just let Origen configure Bundler for you to use its binstubs feature.
If you can't run bundle, then it probably means that Bundler is not installed to your base Ruby installation in this environment.
You should have both Bundler and Origen installed to the base Ruby in order to be able to boot Origen applications.

Related

Git command run with child_process.spawn is unable to find git-lfs subcommand

I've got an electron app (Electron v17.4.10) running on macOS Monterey (v12.5) and on startup it attempts to perform the command git lfs install. It does so by using the Node child_process package's spawn command to invoke a direct call to a standalone git executable.
When the electron app is installed, it provides its own version of git that isn't added to the PATH to prevent interfering with any git versions that may already be installed. The standalone version of git (v2.33.0) has the folder structure shown in the image below and the git-lfs binary (v3.2.0) is contained within /PortableGit/git/libexec/git-core/
Standalone Git Directory Structure
The full command executed is:
"/Applications/MyApp/Utilities/PortableGit/bin/git" lfs install
And the output is:
git: 'lfs' is not a git command. See 'git --help'.
The most similar command is
log
How can I get the standalone installation of git to recognize the subcommand lfs without placing it on the PATH? Is having a self-contained git package like I've described even possible? Or should I abandon the approach and ensure git is installed properly on the target machine?
The answer to this problem is that Electron's process.env is different from the target system's env. So while Git will look for submodules on the PATH, the PATH used in the Terminal will be different from the PATH used by the child process.
Appending a ':' followed by the path to where the git-lfs binary is stored to process.env.PATH will allow the standalone git installation to properly identify git-lfs subcommands.
I.E.
process.env.PATH = process.env.PATH + ":" + "path/to/git/lfs"

Missing binaries during git hook

Let's setup a post-receive hook for git like this:
#!/bin/sh
git --work-tree=/path/to/www --git-dir=/path/to/git/test_CI.git checkout -f
export PATH=$PATH:/usr/bin #(<- this export does not help much)
yarn build
The first line work well, but yarn build fails, because the hook doesn't know yarn at all.
(Running yarn in my host-terminal works perfeclty, though. The host is running on Ubuntu 18.04. by the way.)
which yarn tells me the exact location of yarn:
/home/.../.nvm/versions/node/v12.18.3/bin/yarn
I can use this for the hook. But the path contains the current yarn versionnumber, which will cause other problems, once the systems gets updated.
Plus, nvm, or node or nuxt and so on won't be found next. So this is not a clever workaround.
How can you make all the things that you have access to in your teminal (not only yarn) available for the hook?
export PATH=$PATH:/usr/bin #(<- this export does not help much)
This adds /usr/bin, which should already be part of $PATH to begin with, so... it does not do much.
I would check, as seen in nvm-sh/nvm issue 355 if you can have ~/.nvm/current/ symlink (symbolic link), in order for the $PATH to remain constant, even when npm is updated.

Openshift action_hook is not executable

I have recently create my first Openshift node application and currently trying to get the build scripts working when I push to the server via git (using action_hook).
I am writing the application using PhpStorm on Windows and have had no problem pushing files to the server.
I have create the following file: .openshift/action_hook/build which contains the following:
#!/bin/bash
webpack --config $OPENSHIFT_DATA_DIR/webpack.config.js
When I push to the server using git, I get the following error:
NOTE: The .openshift/action_hooks/build hook is not executable, to make it executable:
On Windows run: git update-index --chmod=+x .openshift/action_hooks/build
On Linux/OSX run: chmod +x .openshift/action_hooks/build
I have tried the windows command above but when running git ls-tree HEAD to check the file permission, I can see they have not changed:
100644 blob 1b82131d8b9e9c63b765ef328ecbbfb54f0c70aa build
Has anybody managed to get this working on windows?
Thanks a lot

Best way to (git) push changes to a development server and have it automatically restart a Node app?

Previously and on my local machine, I've been using nodemon which watches for changes made to a Node app and reloads it upon every change. But running the development server on my own machine is no longer feasible, so I've setup git for the app on a designated development server.
In advance, I prefer Sublime Text, so editing files on the development server via the terminal doesn't match my workflow, plus I like having a copy of everything on my local machine by default. I had also checked out rsync, but I like the fine-grained version control that git offers.
So how can I edit files locally, git push them to a development server, and have the Node app automatically reload after every push?
You can write a server side hook. In your .git directory there is a hook directory. Just cd in to .git/hooks. There you can write a script in whatever language you need to write it in. Essentially after you push it will run the script you tell it to. Here is more information on git hooks
https://git-scm.com/book/es/v2/Customizing-Git-Git-Hooks
Quick tutorial to make this work:
On the development server, navigate to /home/dev-user/Node and initialize bare repository at /home/dev-user/Node/example.git using git init --bare example.git.
Clone repository into /home/dev-user/Node/example using git clone example.git.
Add files to /home/dev-user/Node/example as necessary, then git add . and git commit -m "init" and finally git push origin master which will push those files to example.git.
Edit or create /home/dev-user/Node/example.git/hooks/post-receive and add the following line:
GIT_WORK_TREE=/home/dev-user/Node/example/ git checkout -f
This will automatically update the files in /home/dev-user/Node/example/ upon any changes pushed to /home/dev-user/Node/example.git.
If you don't have nodemon installed already, install it with npm install -g nodemon. You may have to use sudo.
Assuming your main Node app is located at /home/dev-user/Node/example/app.js, start the app using nodemon /home/dev-user/Node/example/app.js (or if you're already within /home/dev-user/Node/example, just nodemon app.js of course).
On your local machine, navigate to /home/timbur/Node, and assuming you're able to connect to the server automatically via SSH, clone the bare repository using git clone dev-user#dev.server.ip.address:Node/example.git. You'll now have everything in /home/timbur/Node/example.
Edit files on your local machine and add/commit/push files to the development server as usual, and changes will automatically update the server's example directory, which nodemon will detect and the app will be restarted.
The best way would be to setup a continuous integration server, like Jenkins: https://jenkins-ci.org/
And then there are plugins for basically whatever you want to do, like this one for node.js for instance: https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
But that's probably not the easiest way. You could also setup a post-receive hook on your server, that checks out the code whenever you push any changes, and then let it restart your server. Here's a gist I found (but never tried) https://gist.github.com/tlrobinson/8035884

Gitlab import: Could not locate Gemfile

I have a test VM with Debian Wheezy and no ruby installed. Gitlab 6.9.2 has been installed using the provided installer which brings an embedded ruby. Now, I want to import some old repos into Gitlab, but I cannot find the correct procedure. I think it should be this way:
su - git
export PATH=$PATH:/opt/gitlab/embedded/bin
cd ~
bundle exec rake gitlab:import:repos RAILS_ENV=production
Though, I only get the error "Could not locate Gemfile". I have tried several other ways, also installing Debians ruby, searched multiple Google and StackOverflow results, but I couldnĀ“t get it to work.
You should first place the bare repos in the repo dir. The default path for omnibus is /var/opt/gitlab/git-data/repositories/<namespace>. Then you just run the rake task:
sudo -u git -H cp -r my-project/.git /var/opt/gitlab/git-data/repositories/<namespace>/my-project.git
sudo gitlab-rake gitlab:import:repos
See invoking rake tasks and the import mechanism.
Edit: Sent an MR upstream to include this info in the readme.
I have run into same issue with "Could not locate Gemfile". So I searched for Gemfile and tried several folders. Until it worked.
The solution is related to Gitlab from source (or in my case it run inside offical docker container).
Place your .git bare repository (or several of them) in
"/var/opt/gitlab/git-data/repositories//my-project.git"
switch to user "git".
su git
Try if you have correct PATH by just "rake". If not available, extend your PATH:
export PATH=$PATH:/opt/gitlab/embedded/bin
after that switch to the shell were the rake command to import your bare projects will work and do the import.
cd /opt/gitlab/embedded/service/gitlab-rails/
bundle exec rake gitlab:import:repos RAILS_ENV=production
Output will be similar to this:
Processing raspberry/apollo-web.git
* Created apollo-web (raspberry/apollo-web.git)
Processing raspberry/apollo-web.wiki.git
* Skipping wiki repo
Processing dhbw/dhbw-prototyping-node-rest-course.git
...
EDIT:
Ok I was happy a bit too early. Although the ouput says it was imported. On the Web GUI no new projects.
I will investiage further...

Resources