creating new agents
Hi, I created custom agent as in https://www.eclipse.org/che/docs/plugins/agents/index.html How do i extend che to show my custom agent while creating workspace. In other words, how do i link this with Che assembly - so that i can start Che with this Custom assembly.
Hi @mvidhya86 - what kind of enhancement are you making?
A couple of resources that I would have you look at: https://www.eclipse.org/che/docs/plugins/agents/index.html https://www.eclipse.org/che/docs/plugins/languageserver/index.html
Also, we are reworking how custom assemblies are generated now using maven archetypes. One of the archetypes that we are testing is one that generates a custom assembly with a custom agent. So you can explore how it is configured. We are baking this into the CLI, but the base utility used for this is documented here - https://github.com/eclipse/che-archetypes. You can run this with maven on the command line and see what an agent generated assembly looks like.
Hi, Thanks for your comments. Am trying to extend the run time of workspace based on new agent. By referring to https://github.com/eclipse/che-archetypes, i generated new agent archetype jar and is available in project's target folder. To integrate this to IDE and to show this new agent on creating workspace, we have some info here - https://www.eclipse.org/che/docs/plugins/create-and-build-extensions/ to start che from custom assembly, i should try this - but any comments would be helpful ..
@mvidhya86 i am a little bit confused. Agents usually install smth in a workspace and run the installed software that provides some functionality.
Can you perhaps share your plugin source code and explain in detail what you are trying to achieve?
Hi, As in https://github.com/eclipse/che-archetypes, agent-archetype i modified the script which will do software installation from a zip file and add some environment variables. Like you mentioned, i need to achieve this functionality in workspace with the help of agent.
After modification of script - i have agent-archetype jar out of build. At this phase - i referenced this jar and added dependency to assembly-ide-war - module of Che and built the same - and continue with the procedure mentioned in https://www.eclipse.org/che/docs/plugins/create-and-build-extensions/ and finally need to load che with the custom assembly.
@mvidhya86 what exactly does not work for you? Have you tried a hello world agent?
Hello World agent does not work.. These are the steps i tried.
Import https://github.com/eclipse/che-archetypes to Che
Agent-Archetype - build and generate jar in Target
Reference it in assembly-ide-war module - add to pom and run mvn sortpom:sort
Please correct me if something needs to be added/changed
Build -> assembly-ide-war => takes lot of time and is stuck maybe this is the problem?
Also, this is confusing - Import https://github.com/eclipse/che-archetypes to Che
The archetype project will generate a new assembly for you. No need to add anything to poms in that assembly
Oh ok - then could you please let me know -what is intended here. I have agent-archetype jar and how do i link this to che assemble or start che with this assembly.
Once you have built a jar, you need to generate an assembly - https://github.com/eclipse/che-archetypes#generate-assembly
After assembly is generated - build it.
Thank you, i will try out this
Hi, I generated the assemble as in https://github.com/eclipse/che-archetypes#generate-assembly. To start che with the generated assemble i used the below command docker run -it --rm -v /usr/local/codenvy/chedata:/data -v /usr/local/eclipse-che-0.1:/assembly -v /var/run/docker.sock:/var/run/docker.sock eclipse/che start
After starting che, i created a workspace with java stack - configure workspace - run time - shows Sample-agent under dev-machine . But on starting workspace - it does not show the 'Hello, Agent!' output. Where do i check this ..
In /agents/$groupID/src/main/resources there's a json. Here's how it looks in my case:
eugene@eugene:~/Stuff/arch/example/agents/example/src/main/resources$ cat codenvy.sample.json
{
"id": "codenvy.sample",
"name": "Sample agent",
"description": "Sample agent",
"dependencies": [],
"properties": {},
"servers": {}
}
ID, is what you should add to your workspace config.
Thank You, this went fine. I tried to update environment variable - PATH in the agent script like this: export PATH=${PATH}:/usr/local/xxx echo $PATH
i have the contents uploaded to /usr/local/xx in script and PATH variable update - though it prints PATH correctly when the workspace starts - execution of command based on xxx fails. but if i do a cd to /usr/local/xx and then execute the same command sit works fine. Is this a known issue ..
@mvidhya86 can you share your script and comment on what you think should happen there?
Please find the script here. I don't see any issues in the script as such, after workspace is created in the terminal, i expect the PATH variable to be shown correctly if i execute env command - currently PATH variable does not show the updated value.
From script.sh:
#
# Copyright (c) 2012-2017
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
unset SUDO
unset PACKAGES
test "$(id -u)" = 0 || SUDO="sudo -E"
if [ -f /etc/centos-release ]; then
FILE="/etc/centos-release"
LINUX_TYPE=$(cat $FILE | awk '{print $1}')
elif [ -f /etc/redhat-release ]; then
FILE="/etc/redhat-release"
LINUX_TYPE=$(cat $FILE | cut -c 1-8)
else
FILE="/etc/os-release"
LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')
LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)
fi
###############################
### Install Needed packaged ###
###############################
# Red Hat Enterprise Linux 7
############################
if echo ${LINUX_TYPE} | grep -qi "rhel"; then
test "${PACKAGES}" = "" || {
${SUDO} yum -y install ${PACKAGES};
}
# Red Hat Enterprise Linux 6
############################
elif echo ${LINUX_TYPE} | grep -qi "Red Hat"; then
test "${PACKAGES}" = "" || {
${SUDO} yum -y install ${PACKAGES};
}
# Ubuntu 14.04 16.04 / Linux Mint 17
####################################
elif echo ${LINUX_TYPE} | grep -qi "ubuntu"; then
test "${PACKAGES}" = "" || {
${SUDO} apt-get update;
${SUDO} apt-get -y install ${PACKAGES};
}
# Debian 8
##########
elif echo ${LINUX_TYPE} | grep -qi "debian"; then
test "${PACKAGES}" = "" || {
${SUDO} apt-get update;
${SUDO} apt-get -y install ${PACKAGES};
}
# Fedora 23
###########
elif echo ${LINUX_TYPE} | grep -qi "fedora"; then
command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" procps-ng"; }
test "${PACKAGES}" = "" || {
${SUDO} dnf -y install ${PACKAGES};
}
# CentOS 7.1 & Oracle Linux 7.1
###############################
elif echo ${LINUX_TYPE} | grep -qi "centos"; then
test "${PACKAGES}" = "" || {
${SUDO} yum -y install ${PACKAGES};
}
# openSUSE 13.2
###############
elif echo ${LINUX_TYPE} | grep -qi "opensuse"; then
test "${PACKAGES}" = "" || {
${SUDO} zypper install -y ${PACKAGES};
}
# Alpine 3.3
############
elif echo ${LINUX_TYPE} | grep -qi "alpine"; then
test "${PACKAGES}" = "" || {
${SUDO} apk update;
${SUDO} apk add openssh ${PACKAGES};
}
# Centos 6.6, 6.7, 6.8
############
elif echo ${LINUX_TYPE} | grep -qi "CentOS"; then
test "${PACKAGES}" = "" || {
${SUDO} yum -y install ${PACKAGES};
}
else
>&2 echo "Unrecognized Linux Type"
>&2 cat $FILE
exit 1
fi
#############
#
echo "Hello, agent!"
#For ALM RTC SCM Tools
echo "get rtc installer to local path"
sudo wget http://fe0vmc1362/jazz_602.zip -O /usr/local/jazz_602.zip
sudo unzip /usr/local/jazz_602.zip -d /usr/local
echo "add to path"
export PATH=${PATH}:/usr/local/jazz_602/scmtools/eclipse/
echo "print env"
echo $PATH
echo "done!"
@mvidhya86
export PATH=${PATH}:/usr/local/jazz_602/scmtools/eclipse/ this will do the trick only for a current terminal session ie only for the script.
If you want to permanently export this env, you may want to try to write it to ~/.bashrc. For example, this way:
sudo echo "export PATH=\$PATH:/usr/local/jazz_602/scmtools/eclipse/" >> ~/.bashrc
sudo echo "export PATH=$PATH:/usr/local/jazz_602/scmtools/eclipse/" >> ~/.bashrc This works perfectly. Many thanks for your hint!
Yo're welcome.