Jump to content
Evgeny

Jenkins, problems with cm on Mac

Recommended Posts

I'm trying to setup iOS build on MacOS and checkout are failing with following error

[TestScripts] $ cm lwk --format={wkname}#{path}#{wkid}
FATAL: Cannot run program "cm" (in directory "/Volumes/LittleBigBOSS/JA1/workspace/TestJobs/TestScripts"): error=2, No such file or directory

 

Pipeline script is very simple and it works if i launch it on Windows Node

node('iOS')
{
    cm branch: context.BranchName, repository: context.SCMRepository, server: context.SCMServer
}

 

I checked all steps manually and they works.

  1. cd to the path "/Volumes/LittleBigBOSS/JA1/workspace/TestJobs/TestScripts"
  2. launched command "cm lwk --format={wkname}#{path}#{wkid}"

Here are shell log for this:

Last login: Fri May 15 23:28:59 on ttys000
bizon:~ admin$ cd /Volumes/LittleBigBOSS/JA1/workspace/TestJobs/TestScripts
bizon:TestScripts admin$ cm lwk --format={wkname}#{path}#{wkid}
default#/Users/admin/wkspaces/default#8b1b592b-f895-4377-b118-d4f1fa7fcbd0
bizon:TestScripts admin$ 

PS

Noticed, that i previously opened shell from admin user. Repeated test, using Jenkins user with same results

Share this post


Link to post
Share on other sites

Maybe i did something wrong on the mac?

I just did another test.

Shell script executed from Jenkins pipeline "cm worspace create ..." returned "cm: command not found"

[Pipeline] sh
+ cm workspace create hc-smf-living-pictures-client /Volumes/LittleBigBOSS/JA1/workspace/hc-smf/hc-smf-living-pictures-client/hc-smf-living-pictures-client --repository=hc-smf/hc-smf-living-pictures-client@__@cloud
/Volumes/LittleBigBOSS/JA1/workspace/hc-smf/hc-smf-living-pictures-client@tmp/durable-62867457/script.sh: line 1: cm: command not found

I copyed the same command in bash and executed it manually and worspace was succesfully created

bizon:TestScripts jenkins$ cm workspace create hc-smf-living-pictures-client /Volumes/LittleBigBOSS/JA1/workspace/hc-smf/hc-smf-living-pictures-client/hc-smf-living-pictures-client --repository=hc-smf/hc-smf-living-pictures-client@__@cloud
Workspace hc-smf-living-pictures-client has been correctly created

What am i missing?

Share this post


Link to post
Share on other sites

Hi,


Could you manually copy the "/Users/xxx/plastic4/client.conf" to the client binaries folder?

/Applications/PlasticSCM.app/Contents/MonoBundle

The Jenkins server may be be run with a different user than yours. By Copying the configuration file in the client binaries folder, all the machine users will use the same Plastic clienbt configuration.

- Also review that "cm" is in the system PATH variable. You can also include the full path in the Jenkins configuration:

/Applications/PlasticSCM.app/Contents/MonoBundle/cm

Regards,

Carlos.

Share this post


Link to post
Share on other sites

Jenkins server is running on Windows and i'm trying to setup agent on MacOS. So i can't use absolute path to cm - that will brake all windows builds.

What i tryed

- Reinstall Plastic under Jenkins user (Should'n this add cm to Path?)

- Add Plastic to /etc/paths 

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/PlasticSCM.app/Contents/MonoBundle

And it didn't work

bizon:TestScripts jenkins$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
bizon:TestScripts jenkins$ sudo open /etc/paths

- I tryed to execute cm in Bash (under Jenkins user) and it works. It seems, that cm is added to Path, but it only visible from Bash. And not visible from scripts.

Share this post


Link to post
Share on other sites

I added all paths to the Agent Path variable and cm began to work trough the shell. It worth mentioning, that you can't add just Plastic path, as it will replace all other paths and event "sh" wouldn't be found.

But cm command from Jenkins Plugin are still failing with the same error.

Share this post


Link to post
Share on other sites

Hi,

I'm reviewing a previous ticket where we spent some tiem debugging the same error when using a Jenkins macOS ssh slave:
 

Quote

 

We've been debugging the issue. It seems to be a reported Jenkins bug affecting us:

https://issues.jenkins-ci.org/browse/JENKINS-17157

When configuring an ssh slave, the environment variables are not loaded. That's the reason why the Plastic "cm" is not being found (even if it's included in the PATH variable for the jenkins user in the MacOS machine).

 

I've tested with the Java Web Start and I'm not able to reproduce the issue:

On the macOS:
- Running:
sudo java -jar agent.jar -jnlpUrl http://MySERVER84/computer/macOsJava/slave-agent.jnlp -secret f5dcf86e0ceed3f22c08bc27fa07d680aff3e11c25452677af4fee218bcfb1aa -workDir "/tmp"

- I'm not using ssh for login.

I can successfully run a build with this configuration. 

 

 

Using the following workaroud the user was able to configure the PATH variable to include "mono" and the "cm" when connecting via SSH:

https://support.cloudbees.com/hc/en-us/articles/229724088-How-to-set-up-a-Jenkins-agent-to-have-the-same-path-as-the-user-when-connected-via-Remote-Desktop-

Regards,

Carlos.

Share this post


Link to post
Share on other sites

Thank you.

I will setup all build process first, using shell. And in a few days i will check that workaround.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...