Closed datsabk closed 7 months ago
@datsabk can you write a failing test for the scenario you're running into? Please note that the default username and email comes from the machine's git
configured username and email.
Hello @joeyguerra , I basically try passing the options via arguments. Ideally it should not prompt me when those options are passed as flag.
my command looks like yo hubot --owner something --name gitbot....
What's happening currently is that all prompts seem to be pushed regardless of whether a default value is passed. I couldnt find the source of this.prompt() function that pushes the prompt. Does it filter in any way?
Update: My apologies. I didn't finish reading your previous questions.
I think you have to call it like yo hubot --owner="something" --name="gitbot" .....
I see. I'm no longer making feature requests to this package because the current recommended way to generate a Hubot instance is as documented in the Hubot repo readme. Would you mind trying that instead? But I haven't added the ability to set the owner properties via cli arguments. You would just update the package.json
directly with those values.
npx hubot --create myhubot --adapter @hubot-friends/hubot-slack
Where myhubot
is the folder you want to create the bot in.
@joeyguerra I have the same issue with prompts for inputs even when arguments are passed. As a result, my image build broke :(
@hontarenko are you able to update your image with the new recommended way?
@joeyguerra Сan you provide an example of Dockerfile with recommended installation way hubot-slack?
@hontarenko what mage are you currently using? What command do you run?
FROM node:20.12
ARG GITHUB_TOKEN
ARG HUBOT_SLACK_TOKEN
ENV GITHUB_TOKEN="${GITHUB_TOKEN}" \
HUBOT_SLACK_TOKEN="${HUBOT_SLACK_TOKEN}"
RUN npm i -g yo@5.0.0 generator-hubot@2.0.1 && \
addgroup hubot && \
adduser --disabled-password --gecos '' --ingroup hubot hubot && \
adduser hubot hubot
USER hubot
WORKDIR /home/hubot
RUN yo hubot --adapter=slack \
--owner="test" \
--name="HuBot" \
--description="HuBot for github actions" \
--defaults && \
npm i axios@1.6.8
COPY trigger-workflow.js scripts/
CMD HUBOT_SLACK_TOKEN="${HUBOT_SLACK_TOKEN}" ./bin/hubot --adapter slack
:tada: This issue has been resolved in version 2.0.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
@hontarenko I pushed a fix for the issue. Please update your Dockerfile to install the latest generator-hubot
and let me know.
Please note that I'm no longer maintaining this template. I recommend using npx hubot --create
as described in the Hubot Readme.
If you're interested in using the latest version of Hubot and the new hubot-slack adapter that works with the latest version of Hubot, here's an updated Dockerfile
for it:
Note: You'll need to create a new Slack app (you might be able to use your existing) and a Slack Bot Token. Here's the doc for it:
https://github.com/hubot-friends/hubot-slack
FROM node:21-alpine
ARG GITHUB_TOKEN
ARG HUBOT_SLACK_TOKEN
ENV GITHUB_TOKEN="${GITHUB_TOKEN}" \
# HUBOT_SLACK_TOKEN="${HUBOT_SLACK_TOKEN}" \
HUBOT_SLACK_APP_TOKEN="${HUBOT_SLACK_APP_TOKEN}" \
HUBOT_SLACK_BOT_TOKEN="${HUBOT_SLACK_BOT_TOKEN}"
RUN addgroup hubot && \
adduser --disabled-password --gecos '' --ingroup hubot hubot && \
adduser hubot hubot
USER hubot
WORKDIR /home/hubot
# RUN yo hubot --adapter=slack \
# --owner="test" \
# --name="HuBot" \
# --description="HuBot for github actions" \
# --defaults && \
# npm i axios@1.6.8
RUN npx hubot --create . --adapter @hubot-friends/hubot-slack --name "HuBot" && \
npm i axios@1.6.8
COPY trigger-workflow.js scripts/
CMD HUBOT_SLACK_APP_TOKEN="${HUBOT_SLACK_APP_TOKEN}" HUBOT_SLACK_BOT_TOKEN="${HUBOT_SLACK_BOT_TOKEN}" npm start -- --name "HuBot"
@joeyguerra With latest version generator-hubot, i am getting an error:
./bin/hubot --adapter slack
@hontarenko I think that error is caused by using the latest version of Hubot (which is installed by the yeoman Hubot generator) and the old Slack Adapter (which is incompatible with the latest version of Hubot).
I think your options are to downgrade Hubot and all of the default Hubot scripts or update to the compatible Slack Adapter (which requires you to get a Slack app token AND a Slack Bot Token https://github.com/hubot-friends/hubot-slack).
I think you can downgrade Hubot and it's default scripts with the following:
In your original version Dockerfile:
RUN yo hubot --adapter=slack \
--owner="test" \
--name="HuBot" \
--description="HuBot for github actions" \
--defaults && \
npm i axios@1.6.8 hubot@4 hubot-redis-brain@2 hubot-diagnostics@1
Looking forward to hearing what path you take.
@joeyguerra With downgraded versions i got dependency conflict:
And if using --force
: {"level":50,"time":1712071439122,"pid":93,"hostname":"40391f503aab","name":"HuBot","msg":"Cannot load adapter slack - Error: Cannot find module 'hubot-slack'\nRequire stack:\n- /home/hubot/node_modules/hubot/src/robot.js\n- /home/hubot/node_modules/hubot/es2015.js\n- /home/hubot/node_modules/hubot/index.js\n- /home/hubot/node_modules/hubot/bin/hubot.js\n- /home/hubot/node_modules/hubot/bin/hubot"}
Ok. --force
might work. Looks like the error is because hubot-slack
isn't installed. I suspect it's because the latest generator-hubot isn't installing it correctly.
Can you please try installing it:
RUN yo hubot --adapter=slack \
--owner="test" \
--name="HuBot" \
--description="HuBot for github actions" \
--defaults && \
npm i axios@1.6.8 hubot@4 hubot-redis-brain@2 hubot-diagnostics@1 hubot-slack --force
@joeyguerra I got the same errors
I think trouble in this function https://github.com/hubotio/hubot/blob/main/src/Robot.mjs#L520-L522
{"level":50,"time":1712144903526,"pid":178,"hostname":"67f22d073dea","name":"HuBot","msg":"Cannot load adapter [no path set] slack - TypeError: (intermediate value).default.use is not a function"}
file:///home/hubot/node_modules/hubot/src/Robot.mjs:523
return await (await import(adapterPath)).default.use(this)
^
TypeError: (intermediate value).default.use is not a function
at Robot.importAdapterFrom (file:///home/hubot/node_modules/hubot/src/Robot.mjs:523:54)
at async Robot.requireAdapterFrom (file:///home/hubot/node_modules/hubot/src/Robot.mjs:519:12)
at async Robot.loadAdapter (file:///home/hubot/node_modules/hubot/src/Robot.mjs:503:26)
at async file:///home/hubot/node_modules/hubot/bin/Hubot.mjs:132:3
Node.js v20.12.0
That error suggests that Hubot version 4 is not being installed. The of the code you posted is in the newer versions of Hubot.
The following Dockerfile
seems to work, but I still recommend you moving to the latest version of Hubot with the new Slack Adapter because the configuration defined below is using unmaintained versions of modules that have a possibility of not working together and won't get updated for any security vulnerabilities.
FROM node:20.12
ARG GITHUB_TOKEN
ARG HUBOT_SLACK_TOKEN
ENV GITHUB_TOKEN="${GITHUB_TOKEN}" \
HUBOT_SLACK_TOKEN="${HUBOT_SLACK_TOKEN}"
RUN npm i -g yo generator-hubot && \
addgroup hubot && \
adduser --disabled-password --gecos '' --ingroup hubot hubot && \
adduser hubot hubot
USER hubot
WORKDIR /home/hubot
RUN yo hubot --owner="test" \
--name="HuBot" \
--description="HuBot for github actions" \
--defaults
RUN npm i axios@1.6.8 hubot@4 hubot-slack
RUN npm i hubot-redis-brain@2 hubot-diagnostics@1 coffeescript@1 --force
RUN rm scripts/Example.mjs
COPY trigger-workflow.js scripts/
CMD ["npm", "start", "--", "--adapter", "slack", "--name", "HuBot"]
Thanks! Problem solved :)
You're welcome. I'm curious, care to share what you're using Hubot for? Is it valuable?
We are using Hubot for triggering github actions workflows with different parameters
@hontarenko What makes it more attractive than just using the Github Actions UI?
Because I use slack integration with github to run github actions workflows from slack commands. Such a business need
Hello @joeyguerra , After your recent changes, the conditional prompts got converted to permanent prompts.
This is how the prompts are expected to be. Instead, it now pushes all prompts even if options are passed. Could you please look into fixing the same.