How can I set run parameter in intellij? - intellij-idea

I know how to set run parameter in eclipse(Run tap -> Run Configuration -> Argument)
I want to do same thing in intellij but there is no Run Configuration Menu How can I set parameter while running app in intellij?

You can pass Program Arguments and Environment Variables under Run | Edit Configurations... | select your configuration:
See https://www.jetbrains.com/help/idea/run-debug-configuration.html#createExplicitly for more information.

Related

Invoke an intelliJ run/debug configuration from command line?

I've got some Run/Debug Configurations defined in my JetBrains IDE, and to run them obviously you'd normally press the green 'play' icon;
However, I want to combine that with scripts I've got on my machine which detect file system changes and re-run some validation steps in the background;
Now what I'd like to do is to say something like 'when the CLI detects that something is stale, start the run/debug configuration in the IDE'.
So in pseudo-bash, something like
# if any "*.rs" file changes, press the green button in intellij;
watch-files *.rs -x "run-intellij-config 'check controlplane'
Is it possible to invoke tasks within IntelliJ like this?
There is no way to do this currently, please vote for IDEA-157076 to be notified on any progress with this feature request

How configure Azure function project in Intellij/Pycharm run/debug configurations on mac

How to configure Azure function project in Intellij/Pycharm run/debug configurations on Mac because I've tried to set it by my own but it doesnt work.
I would like to replace shell command: func start with run config
The image below from Pycharm
UPDATE
I've added path to Azure-CLI and imported my app-settings
I'm trying to configure the run configs but it asks to select the module but there is no any module in dropdown (see pic)
UPDATE-UPDATE:
Here is what azure-tools-for-intellij team me answered:
They dont support pure python functions run yet
I think you shouldn't use row shell scrip with IntelliJ/PyCharm instead of this you should use Azure Toolkit for IntelliJ and run/debug your functions like in this guide.
Also when you install Azure Toolkit for IntelliJ you will have the opportunity to create run/debug configuration with predefined Azure Function ready template.
Just example:
I found the way to debug in Intellij Idea/PyCharm.
add these lines at the top of your file/module:
import pydevd_pycharm
pydevd_pycharm.settrace('127.0.0.1', port=9091, stdoutToServer=True, stderrToServer=True)
set Python Debug Server with host and port in Run/Debug Configs
run your azure functions as used to (func host start) and press debugging button.
The way I do it in PyCharm is to define a shell script configuration (Edit Configurations > Shell Script) and set:
Execute: Script set
Script text: func start
Working directory: should be to project directory where host.json etc. is located
Environment variables: leave empty
Execute in the terminal: checked
Run this configuration, which will start the test server in terminal. Then go to Run > Attach to Process... and select the process (usually it's the one without any path after the number).

How to pass parameter from jenkins to selenium

I'm using jenkins and selenium.
I need to send the testing url to selenium server from jenkins.
Under General Tab
Jenkins String parameter: Name = APP, Default Value = http://localhost/basecode/
Under Post-build Actions
Trigger parameterized build on other projects -> Predefined parameters -> Parameters -> SEL_APP=$APP
Above mentioned SEL_APP value needs to be written in the selenium bat file.
Suggestions are most welcome :-)
If you are using maven then you can pass the parameters through maven command.
mvn clean test -Duser=value1 -Dpass=value2
If you are building the Jenkins job with parameters then you can use jenkins parameters in maven command as
clean test -Duser=$jenkinsparam1 -Dpass=$jenkinsparam1
jenkinsparam1 - Jenkins parameter while building a job.
In the code you can use them as
String s1 = System.getProperty("user");
String s2 = System.getProperty("pass");
Use File Operations Plugin to create a bat file.
Add File Operations build step and with in it add File Create Operation. It creates the bat file with the contents provided in text area.
Use %parameter_name% in your bat file, it would directly pick it from Jenkins.

How to run Apache Tomcat 8 in debug mode?

I am trying to run Apache Tomcat 8.0.21 in debug mode.
When I give the command
sh catalina.sh jpda start
it gives this error.
error message
ERROR: Cannot load this JVM TI agent twice, check your java command
line for duplicate jdwp options. Error occurred during initialization
of VM agent library failed to init: jdwp
Can anyone help ?
Either
unset CATALINA_OPTS
unset JPDA_ADDRESS
unset JPDA_OPTS
unset JPDA_TRANSPORT
catalina.sh jpda start
Or
# in .bashrc, .profile etc.
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 -Djava.security.egd=file:/dev/urandom -Denv=dev -Xms1024M -Xmx2048M -XX:PermSize=256M -XX:MaxPermSize=768m"
# At your shell prompt
./startup.sh
Explanation
As Arnab said in the comments, if your shell configuration includes environment variables mentioning jdpw (such as CATALINA_OPTS, JDPA_ADDRESS, JPDA_OPTS), just launch using ./startup.sh as if you were not trying to do remote debugging and the script will pick up the jdpw option from your environment variables.
The launch option syntax catalina.sh jpda start should only be used if you don't have any environment variables that already specified a remote debug port. It's meant to be convenient but if you've previously configured your shell to support java remote debugging you're probably mixing the two alternative approaches.
You can just add env variable and run the tomcat as usual
Debug port is 8000 in this case
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Then run the tomcat
sh ./catalina.sh start
This happened to me with Eclipse when I tried to add the debugging parameters (-Xdebug -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y) so I could suspend Tomcat on start. Unfortunately I then launched my Tomcat (within Eclipse) using the Debug button.
Why this is a problem
When you are launching Tomcat in Debug mode Eclipse itself inserts the debug parameters. When you have your own debug parameters in the launch configuration you are indeed passing them twice.
So if you need to launch Tomcat from within Eclipse and suspend it on start (so you can connect with debugger) you need to:
- add the debugging parameters to the "Arguments -> VM arguments" box of your launch config,
- and then Run this config, not Debug.
This way only the debugging parameters from your launch config are added.
There is alternative approach, recommended in 'catalina.sh':
"Do not set the variables in this script. Instead put them into a script
setenv.sh in CATALINA_BASE/bin to keep your customizations separate."
For Windows, the file name with environment variables will be 'setenv.bat'.
Thank you mr Dimitar II
Verified this works perfectly and is consumed automatically when running startup.bat
file: setenv.bat
#echo off
rem The proper way to set environment up for running Catalina
set "CATALINA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"

How to run Play Framework 2.x in debug mode in IntelliJ IDEA?

I want to run Play Framework 2.x in debug mode in IntelliJ IDEA. I searched in the Internet and all results say that you have to use play console.
Is it possible to run in debug mode in IntelliJ IDEA without using play console?
Using activator :
From Terminal (Not intellij terminal), enter command : activator ui
Open your existing app
Choose "Code view & Open in IDE
In Browse Code, click setting icon
Choose Open Project in Intellij IDEA
Generate
Open Intellij IDEA
Open project - browse your app directory
Run - Edit Configuration
Add new configuration - Remote
Add name
Setting
transport : socket, debugger mode : attach, Host : localhost, port : 9999
module clashpath : your app
Tools - Open Terminal
activator -jvm-debug 9999 run
Run debug
Open browser localhost:9000
You need to use Idea 12+ Ultimate Edition
Install Play 2.0 Support, Scala and other required plugins in Idea
In command line perform play idea to generate project
Open created project in Idea (open, don't import)
Go to: Menu > Run > Edit Configurations... > Add New Configuration... > choose Play 2 App
In Menu > Run new buttons will appear Debug and Run, first will run app with enabled debbuger.
Preparation: Do not use the project creation by activator ui or similar. Just
open the project in IntelliJ.
activator -jvm-debug 9999 ~run. The ~ before run enables automatic reloading of generated HTML pages
In IntelliJ:
Run > Edit Configurations...
Select Defaults/Remote
Click on the green + at the upper left corner
Give the name "Play 2"
Ensure that Transport:Socket and Debugger mode:Attach are selected
Type in 9999 as port
Press "OK"
Run > Debug Play 2 (second entry in the list)
Pro hint: Check out the play-auto-refresh plugin to have Chrome automatically reloading on a change.
(based on #ARM's answer)
Open Intellij IDEA
Open project - browse your app directory Run - Edit Configuration
Add new configuration - Play2
Add http://localhost:9000 to url to open option
Add -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M to JVM option
Set Debug port to 9999
Set your debug point and debug your application. Cheers :)
FYI : All of the above fields might filled up already
this works for me and maybe easier
file menue => settings => Build, Execution, Deployment => sbt => check "Enable debugging for sbt shell"
idea sbt shell now will start with debug enable, log out the port as "Listening for transport dt_socket at address: 52701"
Run/Debug Configurations => Add(the pluss(+) sign) => Remote => Set "Port" And "Use module classpath"
just type run in sbt shell, then click debug button
screent shot
enable idea emaded sbt debug
sbt shell start log
add remote in "Run/Debug"
type run here