ant build script for behat error - linux

I am trying to setup an ant build script for behat tests so I can run them from jenkins. When I run behat from the command line with bin/behat or ./bin/behat, the output works as expected. But when I use the following ant script
<project name="behat" basedir=".">
<exec dir="bin" executable="./behat">
</exec>
</project>
I get this error:
Buildfile: <mydir>/build.xml
[exec]
[exec]
[exec]
[exec] [RuntimeException]
[exec] Context class not found.
[exec] Maybe you have provided wrong or no `bootstrap` path in your behat.yml:
[exec] http://docs.behat.org/guides/7.config.html#paths
[exec]
[exec]
[exec]
[exec] behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]
[exec]
[exec]
[exec] Result: 1
BUILD SUCCESSFUL
Total time: 0 seconds

You shouldn't be running behat from the bin directory. It won't find your behat.yml file.
You should either run it like this:
./bin/behat
or pass a path to the config file:
cd bin
./bin/behat --config ../behat.yml
I haven't tried the later. Your ant script might look something like:
<project name="behat" basedir=".">
<exec dir="${basedir}" executable="./bin/behat" />
</project>

I took ant out of the equation and just used jenkins to run the behat commands directly:
cd <mydir>
bin/behat
One thing I need to check is the build from jenkins returns failed, but it may be due to the behat tests are failing.

Related

Rust - Failed to create package

I'm following the basic steps here: file:///Users/leongaban/.rustup/toolchains/stable-x86_64-apple-darwin/share/doc/rust/html/book/ch01-03-hello-cargo.html
I checked my cargo version, and cd .. back up to my root project folders and ran the following command to create a new project:
cargo new hello_cargo
And it threw the following error:
error: Failed to create package hello_cargo at /Users/leongaban/projects/rust_projects/hello_cargo
However when I run ls it did create the folder? So I'm curious how do I avoid that error in the future?
rust_projects % cargo new hello_cargo
error: Failed to create package `hello_cargo` at `/Users/leongaban/projects/rust_projects/hello_cargo`
Caused by:
could not find '/Users/leongaban/.git-templates/' to stat: No such file or directory; class=Os (2); code=NotFound (-3)
rust_projects % ls
hello_cargo hello_world
This maybe caused by git init command invoked when you run cargo new, the source code is as below:
if !path.join(".git").exists() {
// Temporary fix to work around bug in libgit2 when creating a
// directory in the root of a posix filesystem.
// See: https://github.com/libgit2/libgit2/issues/5130
paths::create_dir_all(path)?;
GitRepo::init(path, config.cwd())?;
}
And the .git-templates is documented under git init TEMPLATE DIRECTORY section.
The template directory will be one of the following (in order):
the argument given with the --template option;
the contents of the $GIT_TEMPLATE_DIR environment variable;
the init.templateDir configuration variable; or
the default template directory: /usr/share/git-core/templates.
So you should check above 4 possible cause to setup the non-exists folder '/Users/leongaban/.git-templates/' as git tempalte dir when run git init.
I also had this problem. My environment:
System: MacOS Catalina (version: 10.15.7)
Rustc version: rustc 1.51.0
Solution:
rustup self install
curl https://sh.rustup.rs -sSf | sh
I had a template defined in my gitconfig
[init]
templatedir = /Users/johndye/.git-templates
I am not sure when this got added or why but commenting it out got me past this error

Unable to run bash script with ant exec task

I am trying to execute a bash script from ant exec task.
<target name="test" unless="${is.windows}">
<chmod file="./abc.sh" perm="a+x"/>
<exec dir="./" spawn="false" executable="bash" newenvironment="false">
<arg line="abc.sh ${some-argument}" />
</exec>
</target>
The bash script has shebang #!/bin/bash.
When I run the target, it gives me following output on our Jenkins machines where production code is built. It works fine on my local CentOS machines. Most of the lines are empty. On line 19, it has { (opening curly brace) -
[exec] abc.sh: line 2:
[exec] : command not foundabc.sh: line 7:
[exec] : command not foundabc.sh: line 8:
[exec] : command not foundabc.sh: line 12:
[exec] : command not foundabc.sh: line 14:
[exec] : command not foundabc.sh: line 17:
[exec] : command not foundabc.sh: line 19: syntax error near unexpected token `{
[exec] 'abc.sh: line 19: `{
[exec] '
[exec] Result: 2
It turns out that dos line endings was the problem. Setting svn eol property to native fixed the issue. As on our Jenkins server, the code is checked out for every build, the bash scripts being edited on Windows created line endings incompatible with centOS.

How to run LDAP delete entry tool in linux using ANT task

In linux, I am able to run ldapdelete like this
sudo ldapdelete -x -w 1234 -D "cn=Manager,o=project1" -r "o=project1"
now I want to do this using ANT task:
<target name="ldap-delete">
<exec executable="ldapdelete" failonerror="false">
<arg value="-x"/>
<arg value="-w"/>
<arg value="${ldap.password}"/>
<arg value="-D"/>
<arg value=""${ldap.rootdn}""/>
<arg value="-r"/>
<arg value=""${ldap.entry}""/>
</exec>
</target>
but it failed when running ANT:
[exec] ldap_bind: Invalid DN syntax (34)
[exec] additional info: invalid DN
[exec] Result: 1
what is wrong with my ANT task script?
Thanks
according to martin clayton's comment, I removed quotes around the -D and -r arg values like this:
<arg value="-D"/>
<arg value="${ldap.rootdn}"/>
<arg value="-r"/>
<arg value="${ldap.entry}"/>
and run ant with verbose mode, I got the following error:
[echo] ldapdelete...
[exec] Current OS is Linux
[exec] Executing 'ldapdelete' with arguments:
[exec] '-x'
[exec] '-w'
[exec] '1234'
[exec] '-D'
[exec] 'cn=Manager,o=project1'
[exec] '-r'
[exec] 'o=project1'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] ldap_search: No such object (32)
[exec] ldap_delete: No such object (32)
[exec] Result: 32
ended up with a solution myself:
<target name="ldap-delete">
<exec executable="ldapdelete" failonerror="false">
<arg line="-x -w ${ldap.password} -D "${ldap.rootdn}" -r "${ldap.entry}""/>
</exec>
</target>

Gradle Build sample fails with "You must assign a Groovy library to the 'groovy' configuration."

I have a build.gradle file (from the custom plugin example in the manual) that reads:
apply plugin: 'groovy'
dependencies {
compile gradleApi()
compile localGroovy()
}
But when I run I get:
$ gradle build
:compileJava UP-TO-DATE
:compileGroovy
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> You must assign a Groovy library to the 'groovy' configuration.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Any idea what I am missing?
Ensure you have both:
apply plugin: 'groovy'
and use the groovy keyword in the dependencies section (rather than using the compile keyword):
dependencies {
groovy 'org.codehaus.groovy:groovy-all:2.0.8
}
All credit to this blog.
Short answer, upgrade to a newer version.
The above problem (and a few more) where happening on v1.0.8, upgrading to v1.6 and its all works properly

Openlaszlo migration issues

When i am trying to migrate the code from OL 3.3 to 4.9 i am getting this error. I have followed the steps mentioned here.
http://wiki.openlaszlo.org/Runtime_Differences
But still i am getting this error.
[exec] Exception in thread "main" java.lang.NullPointerException
[exec] at org.openlaszlo.compiler.ClassModel.sortKey(ClassModel.java:235)
[exec] at org.openlaszlo.compiler.ClassModel.compareTo(ClassModel.java:244)
[exec] at java.util.TreeMap.put(TreeMap.java:560)
[exec] at java.util.TreeSet.add(TreeSet.java:255)
[exec] at java.util.AbstractCollection.addAll(AbstractCollection.java:334)
[exec] at java.util.TreeSet.addAll(TreeSet.java:312)
[exec] at java.util.TreeSet.<init>(TreeSet.java:160)
[exec] at org.openlaszlo.compiler.ViewSchema.resolveClassModels(ViewSchema.java:362)
[exec] at org.openlaszlo.compiler.Compiler.updateRootSchema(Compiler.java:809)
[exec] at org.openlaszlo.compiler.Compiler.compile(Compiler.java:452)
[exec] at org.openlaszlo.compiler.Compiler.compile(Compiler.java:199)
[exec] at org.openlaszlo.compiler.Main.compile(Main.java:463)
[exec] at org.openlaszlo.compiler.Main.lzc(Main.java:402)
[exec] at org.openlaszlo.compiler.Main.main(Main.java:105)
Has anyone come across the same type. Please let me know what is the solution.
The problem existed even in the 5.0 version but later by removing the dependencies one by one, i found that one of the class's default placement value is a constraint when i remove the constraint and give the proper name. The error was resolved.

Resources