Jenkins server is not accessible by host name (ip address) - networking

I setup jenkins on my Mac OS X with homebrew and it works just fine via http://localhost:8080 or http://127.0.0.1:8080
I couldn't access jenkins instance via hostname/ipaddress:
1. http://myjenkinshost.local:8080
2. http://192.168.0.100:8080
Both links are not accessible even from local computer (jenkins host itself).
Same time commands ping 192.168.0.100 and ping myjenkinshost.local work just fine.

It turned out that launch agent was configured to listen only 127.0.0.1 (or localhost).
To fixed that edit jenkins agent's plist:
nano /Users/admin/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
and modify httpListenAddress to 0.0.0.0 instead of 127.0.0.1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=0.0.0.0</string>
<string>--httpPort=8080</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

The correct location of the file to edit is /usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist
Found the answer here

At my macOS 11.4 Big Sur installation the plist file was found here:
/opt/homebrew/Cellar/jenkins-lts/2.xxx.x/homebrew.mxcl.jenkins-lts.plist
Changing ip address to 0.0.0.0 worked as described.

By starting jenkins using sudo /etc/init.d/jenkins restart instead of sudo service jenkins start started the browser access. I hope it will be helpful.

I came across something like this but, it was for windows,I'm sure the steps to resolve will be the same,Please give it a try:
https://apple.stackexchange.com/questions/31376/how-can-i-open-port-8080-of-mac-os-x-lion

If your Jenkins running through Homebrew (macos), don't touch /Users/admin/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
Use this one: /usr/local/Cellar/jenkins/2.xxx/homebrew.mxcl.jenkins.plist
Change httpListenAddress to 0.0.0.0

If you have installed Jenkins LTS using Homebrew(macos)
macOS Installers for Jenkins LTS
The path of the file homebrew.mxcl.jenkins-lts.plist is:
/opt/homebrew/opt/jenkins-lts/homebrew.mxcl.jenkins-lts.plist
Since the the folder opt is a hidden folder on macOS. You will need to do the following to see it in finder.
Open Macintosh HD in finder -> and press cmd + shift + [.]
This will reveal all hidden folders.
You now have everything you need to make the required changes. As stated in previous answers.

If your Jenkins running through Homebrew (macOS Big Sur),
First things first, you need to unhide the hidden folders.
Since the folder is a hidden folder on macOS. so you will need to do the following things to unhide the folder.
Open Macintosh HD in finder -> and press cmd + shift + . (dot)
This will reveal all hidden folders.
After you unhidden the folder, paste the below command in the terminal:
nano /usr/local/Cellar/jenkins-lts/2.xxx/homebrew.mxcl.jenkins-lts.plist
Change httpListenAddress 127.0.0.1 to 0.0.0.0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=0.0.0.0</string>
<string>--httpPort=8080</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Once the above steps are done, you can access the Jenkins using hostname or public ip address.

Related

Why does my zsh script works standalone but not when called by launchd?

I seeking help for to setup a periodical job on my imac with macOS Big Sur v11.4.
What I want to do, is to delete all contents of a given folder every 60 seconds with a bash or zsh script. It doesn't matter which one. Default for terminal is set to zsh. Therefore I tried it with zsh.
My current approach is to have two files. A zsh script which deletes the folder contents and for 'launchd' I have a plist which periodically should calls the script.
If I call the zsh script in terminal it works fine and deletes the folder contents.
But when it is called by launchd it returns with "no matches found" and I don't know where the problem is.
Therefore it would be very kind, if someone can help me with this.
/Library/LaunchDaemons/com.deleteGCODE.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.deleteGCODE.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/deleteGCODE.sh</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
<key>StandardErrorPath</key>
<string>/tmp/mycommand.err</string>
<key>StandardOutPath</key>
<string>/tmp/mycommand.out</string>
</dict>
</plist>
/usr/local/bin/deleteGCODE.sh:
#!/bin/zsh
dir="/Users/simon/Documents/Simplify3D/GCODE/"
rm -rf "$dir"*
the output of /tmp/mycommand.out:
/usr/local/bin/deleteGCODE.sh:3: no matches found: /Users/simon/Documents/Simplify3D/GCODE/*
p.s.
I am very sorry that I have postet my previous message in the wrong section.
Hopefully this time it is correct.

Sandboxing QtWebengine for apple store

For the last 4 days I've been trying to publish my app in the apple store (which I've never done before). In it I use qt 5.12.1 with qtwebengine. But I really got stuck with sandboxing webengine because after sandboxing app won't even start. I followed this https://mediaarea.net/blog/2018/02/14/QtWebEngine-MacAppStore initially without recompiling and changing webengine but afterwards doing this as well (Unsuccessfully though 'cause they used qt 5.9). I tried as well suggestions from this thread https://forum.qt.io/topic/102212/qtwebengine-signing-issues/4 but had no luck. So I thought maybe you guys could give me some tips on how could I do this. Here's my script for signing package.
echo SIGN PACKAGE
# special case for QtWebEngineCore
find dist/MyApp.app -name Info.plist -exec plutil -replace CFBundleIdentifier -string "com.MyApp.desktop" {} \;
find dist/MyApp.app -name _CodeSignature -exec rm -fr {} \;
find dist/MyApp.app -name "*.dSYM" -exec rm -fr {} \;
# 1*
for f in $(find dist/MyApp.app/Contents/Frameworks -name '*.framework' -type d)
do
codesign --force --verbose -s "3rd Party Mac Developer Application: MyApp (*)" $f
done
for f in $(find dist/MyApp.app/Contents -name '*.dylib' -type f)
do
codesign --force --verbose -s "3rd Party Mac Developer Application: MyApp (*)" $f
done
codesign --entitlements app/MyApp.entitlements -s "3rd Party Mac Developer Application: MyApp (*)" dist/MyApp.app/Contents/MacOS/MyAppUpdater
codesign --entitlements app/MyApp.entitlements -s "3rd Party Mac Developer Application: MyApp (*)" dist/MyApp.app/Contents/MacOS/crashpad_handler
# 2*
codesign --force --verify --verbose -s "3rd Party Mac Developer Application: MyApp (*)" --entitlements app/MyApp.entitlements dist/MyApp.app
codesign --force --verify --verbose --sign "3rd Party Mac Developer Application: MyApp (*)" --identifier "com.MyApp.desktop" --entitlements app/webengine.entitlements dist/MyApp.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app
# 3*
codesign --entitlements app/MyApp.entitlements -s "3rd Party Mac Developer Application: MyApp (*)" dist/MyApp.app/Contents/MacOS/MyApp
It is kinda mixture of all suggestions of those posts. Eventually I managed to get rid of all apple errors except of this one.
ITMS-90296: App sandbox not enabled - The following executables must include the "com.apple.security.app-sandbox" entitlement with a Boolean value of true in the entitlements property list: [( "com.MyApp.desktop.pkg/Payload/MyApp.app/Contents/MacOS/MyApp" )] Refer to App Sandbox page at https://developer.apple.com/devcenter/mac/app-sandbox/ for more information on sandboxing your app.
The problem with it is if I move part where I sign webengine to (1*) I'll get my app through apple checks but it will crash. But if I leave it where it is right now I will receive error above. I had initially 3* above 2* and tried the combination of moving around webengine signature.
For more details I will attach my MyApp.plist, MyApp.entitlements and webengine.entitlements below.
I run macos mojave 10.14.3 on VirtualBox, qt 5.12.1
webengine.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.inherit</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
</dict>
</plist>
MyApp.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>MyApp</string>
<key>CFBundleExecutable</key>
<string>MyApp</string>
<key>CFBundleIdentifier</key>
<string>com.MyApp.desktop</string>
<key>CFBundleSpokenName</key>
<string>MyApp</string>
<key>CFBundleGetInfoString</key>
<string>blalba</string>
<key>CFBundleIconFile</key>
<string>MyApp.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone is required for voice messages and calls</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<false/>
<key>CFBundleVersion</key>
<string>0.5.1225</string>
<key>CFBundleShortVersionString</key>
<string>0.5.1225</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.social-networking</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
MyApp.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.inherit</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
I ran out of ideas and information of how to solve this problem. One more problem is that I've never published app in apple store before and I don't usually develop under macos as well. So everything is new to me(love it). And if I don't do this my team lead is going to hang me if I don't do this myself first.
So any help appreciated.

Configuring phpStorm and XML for phpUnit 7 (remote) Coverage

I'm playing for a week with phpUnit.
I'm slowly going forward with documentation at:
https://phpunit.readthedocs.io
At this point I'm at code Coverage. I've managed to generate small test --coverage-html (via console). I want everything to work via phpStorm.
I'm struggling with inclusion paths. I can see errors in console, but these aren't to helpful at all.
This is how my console output looks like:
This is the only place I use this file in
This is how folder structure for tested and displayed (in console) file looks like
|- dir:Boostrap
|- dir:Coverage
|- dir:Database
|- dir:Interfaces
|- dir:Methods
|---- file: BasicCalculations.php (line 3 inclusion)
|- dir:Tests
|---- file:DataDisplayingTest.php (file that I'm testing)
|---- dir:Data Providers
|-------- file:BasicCalculationDataProvider.php (line 4 inclusion)
What I've tried/What I've made so far
Cannot find PHPUnit in include path phpstorm (I'm not doing this via composer/vendor so this is not helping, my remote machine is for all the debugging, calculations etc).
PHPUnit test suite include path - this gave me idea to play around with bootstrap file, where I've included all the required files, but again this worked only via manually running tests in console - I want to make it work in phpStorm remotely.
PHPUnit's whitelist and blacklist seem to be ignored . At this point situation looks like this
without processUncoveredFilesFromWhitelist="true" I've got no inclusion error, but I got just more errors after that:
It looks like it's trying to work as console gets green for a moment and I've got the Coverage panel now, but I bet this errors shouldn't be there. I can't be sure If coverage report is being displayed correctly at all.
PHPUnit error "Failed to open stream: No such file or directory" - I've tried the DIR as You can see,
https://github.com/sebastianbergmann/phpunit/issues/1932 - this helped me a bit, now I know I can/have to import xml, and this way I don’t have to generate coverage report remotely via ssh
This is how my phpunit.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
cacheResult="true"
verbose="true">
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>/var/www/html/phpUnit</directory>
</whitelist>
</filter>
<php>
<includePath>/var/www/html/phpUnit</includePath>
</php>
</phpunit>
I've played around with directory/incluedPath, tried variation like:
- /var/www/html/phpUnit
- /var/www/html/phpUnit/
- .
- ./
- <file>pointed/tested/file/here/</file>
I'm working with:
phpStorm
phpUnit 7.x Remotely
php 7.x Remotely
xdebug Remotely
To be more clear:
what am I doing wrong?
how can I deal with inclusions problems?
what is causing all this inclusion path problems?
I’ve manage to solve all the problems I had. I’ve used some of the informations provided in the links I’ve pointed above.
First of all
Include errors
PhpUnit xml uses directive includePath, which in my case looked like this:
<php>
<includePath>/var/www/html/phpUnit</includePath>
</php>
Generally at this point the problem is with… existence of includePath in xml file. This attribute changes the inclusion path.
So lets say that You got project structure like that:
- dir: Classes
–- dir: A
–-- file: A.php class: A (extends B)
–- dir: B
–-- file: B.pphp class: B
-file: index.php
So from the look of file A.php You would need to include B.php like that:
../B/B.php
Since the working directory is
/var/www/html/phpUnit/Classes/
But now since You’ve set up inclusion path to:
var/www/html/phpUnit
File A, tries to load file B from the perspective of phpUnit folder, and it’s kinda looking for file in:
var/www/html
Not having this directive is not solving the problem as phpUnit seems to use some other default path.
I’ve solved this problem by changing the way I include files in project:
Just instead using:
include_once '../Interfaces/BasicCalculationsInterface.php';
I’ve started doing it like this:
include_once __DIR__.'/../Interfaces/BasicCalculationsInterface.php';
This way:
Single files tests work fine
Project itself works fine
phpStorm detects methods, classes etc in included file
Group tests work well too
Writing file index.html permission denied
I’ve stumbled upon this problem as well. This actually is some kind of phpStorm issue, which I don’t know how to solve permanently but I’ve dealt with it for the xml file from which I can run all my tests.
Basically phpStorm added some default configurations for executed tests.
In menu go to
Run/Edit Configurations
Take a look at field Test Runner options.
In my case phpStorm added
--coverage-html /
Everything would be fine, but I use Ubuntu on laptop as remote host, and phpStorm tries this way to create files in / directory for which there is no writing permission. Changing this to some writeable folder or removing this line solved the problem.
And that’s all, this is how my xml file looks like at this point (just in case someone would like to have something to look at)
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
verbose="true">
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">/var/www/html/phpUnit</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="/var/www/html/phpunit/coverage.xml" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-html" target="/var/www/html/phpUnit/phpStormCoverageTest" lowUpperBound="35"
highLowerBound="70"/>
</logging>
<testsuites>
<testsuite name="allTests">
<directory suffix="Test.php">/var/www/html/phpUnit/Tests</directory>
</testsuite>
</testsuites>
</phpunit>
Preview of working html/phpStorm coverage

Symbolic link for plist launch daemon

I need to store plist in web folder. Is it possible to create a symbolic link for this plist from the /library/launchDaemon directory?
ln -s /Library/LaunchDaemons/parag.plist

encrypting web.config failed error

I know that ppl have already asked questions regarding encrypting web.config.
im also trying to encrypt my test config file, but im getting this error.
aspnet_regiis -pef "connectionStrings" "C:\encryptedWeb.config"
Encrypting configuration section...
The configuration for physical path 'C:\EncryptedWeb.config' cannot be opened.
Failed!
I just want to know, what could be reasons that it failed.
I got the answer, it was the readonly property of the web.config which was the problem.
After I removed the readonly It worked like a charm.
for the command "aspnet_regiis -pef" the path of configuration file is the physical path (Not virtual) and also it is the path of directory/folder where web.config resides. So one should not include the name of file in path e.g.
if your web.config path is at D:\MyConfiguration\web.config then while encrypting/decrypting you will use it as follow:
encrypt:
aspnet_regiis -pef [sectionName] "D:\MyConfiguration"
decrypt:
aspnet_regiis -pdf [sectionName] "D:\MyConfiguration"
I know this is old, but I've just had the same issue and none of the other answers got the problem.
You're not supposed to put the filename in the path, and the file MUST be called web.config. So for your example, if your web.config file is actually in C:\ you would put:
aspnet_regiis -pef "connectionStrings" "C:\"
and your file MUST be called web.config as the tool will only look for that file.
For those people whose file isn't in C:\ you'll need to put the full path to the file (root of the site). You'll also need to cd into the directory containing the aspnet_regiis.exe file or put the full file path for the tool as well:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef "ConnectionStrings" "C:\Ghron\Projects\Company\trunk\project1\project1"
Also, some of the other answers are valid points - the parameters are case sensitive, so your paths and section names must be in the right case. I wasted about 20 minutes using "ConnectionStrings" instead of "connectionStrings" (lower case c).
The Sections are CASE SENSITIVE.
Do not Add \ at the end of the path (no web.config needed).
You don't need to do it straight on a site; instead, copy the file to any location.
Encrypting:
aspnet_regiis -pef "SECTIONTOENTRYPT" "d:\tempEnCrypt" -prov WhateverProviderYouAreUsing
Decrypting:
aspnet_regiis -pdf "SECTIONTOENTRYPT" "d:\tempEncrypt"
You can use this to encrypt an app.config as well, just rename the file for the encryption/decryption as web.config
Encrypt/Decrypt web.config
source is taken from this link https://mywebanecdotes.com/2016/09/17/encrypting-credentials-in-app-config-for-multiple-machines/
Firstly, if you have App.config, you need to rename to Web.config. And when done rename it back. This is because aspnet_regiis.exe recognize only Web.config file.
Then create a custom attribute SecuredSettings(any name is fine) either in you App.config or Web.config file.
<configuration>
<configSections>
<section name="SecuredSettings" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<SecuredSettings>
<add key="pwrd" value="password" />
</SecuredSettings>
<configProtectedData>
<providers>
<add keyContainerName="MyCustomKeys"
useMachineContainer="true"
name="MyEncryptionProvider"
type="System.Configuration.RsaProtectedConfigurationProvider"/>
</providers>
</configProtectedData>
</configuration>
In C# you can retrieve these values as you would do it normally. eg:
var attr = ConfigurationManager.GetSection("SecuredSettings") as NameValueCollection;
var value = attr["pwrd"];
The rest is ecrypting or decrypting
Run cmd As Administrator , and locate to C:\Windows\Microsoft.NET\Framework\v4.0.30319
"Create a public/private RSA key pair with a specfic container name. They should also be marked as exportable (otherwise what is the point!)"
aspnet_regiis.exe -pc MyCustomKeys -exp
"Grant permissions for accounts to access the container"
aspnet_regiis.exe -pa MyCustomKeys "NT AUTHORITY\NETWORK SERVICE"
"The following line will now encrypt your section (the pwdr value). The -pef switch is telling the application to look for a web.config file and to use provider that is declared in the beginning (which is using type RsaProtectedConfigurationProvider)"
aspnet_regiis.exe -pef "SecuredSettings" "C:\DEV\ConsoleApp\DEX" -prov MyEncryptionProvider
Export those Keys to another machine (if needed)
aspnet_regiis.exe -px MyCustomKeys keys.xml -pri it will generate keys.xml file in C:\Windows\Microsoft.NET\Framework\v4.0.30319
copy this file and put it in another machine where you would like to use it, to the same location C:\Windows\Microsoft.NET\Framework\v4.0.30319, and run:
aspnet_regiis -pi MyCustomKeys keys.xml
after you can delete the file from both sides.
Don't forget to rename Web.config to App.config, if you did so at the beginning.
TO Decrypt the file:
aspnet_regiis.exe -pdf "SecuredSettings" "C:\DEV\ConsoleApp\DEX"
I was experiencing the same problem and here's what worked for me:
add the aspnet_regiis tool's folder path to your %PATH% variable. This ensures that the tool is accessable from any folder in your command line. See this page for a brief explanation of how to add %PATH% variables: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
navigate to your web root folder (don't know if this is necessary but that's where I was navigated when I executed the command)
execute the command with the -pe argument and the -app argument like such:
aspnet_regiis -pe {section to encrypt} -app "{path from root folder to app, like: "/myappname", use quotes}
Take a look at this , see if you set it up correctly
http://msdn.microsoft.com/en-us/library/ms998283.aspx
A possibiliity is to specify the site with
-site "SiteName"
otherwise it will use the default web site.
You could try and use this tool to encrypt you web config
I am having same issue while encrypting configuration file from a web site.
Provide command to encrypt from a site and not default website.
Below command works when application is in defaultwebsite:
aspnet_regiis.exe -pe "connectionStrings" -app "/sitename" -prov "DataProtectionConfigurationProvider"
I got an "illegal characters in path" error that went away when I removed the double quotes that surrounded my path name. Doesn't make any sense, but there you are.
I also wrote a PowerShell script to do the encrypt/decrypt without dealing with aspnet_regiis : https://github.com/mhenry1384/EncryptDecryptConfig
Don't forget to run CMD as administrator, as I did today, if your servers make use of that feature. Quite a simple mistake to make.

Resources