Cloudbees play plugin set run-time parameters - playframework-2.1

I am trying to set a runtime parameter java_version for my Play 2 app. How could I set runtime parameter using sbt-cloudbees-play-plugin?
Cloudbees SDK
$ play dist
$ bees app:deploy -a a -t play2 -R java_version=1.7 dist/myapp.zip
Build.scala
val main = play.Project(appName, appVersion, appDependencies)
.settings(cloudBeesSettings :_*)
.settings(
CloudBees.applicationId := Some(""),
CloudBees.deployParams := Map("runtime.java_version" -> "1.7")
)

I guess sbt-cloudbees-play-plugin just don't let you pass such option
But as you've set runtime parameter once you don't need to set on all deployments, it's tied to application ID.

Related

Global environment variables for gitlab CI runner

I am working to set up a gitlab runner for multiple projects, and we want to be able to set up environment variables for all of the projects. I tried to set global variables in the .bashrc for both the gitlab-runner and root users but it did not recognize them during the CI script. What is the correct location to declare global environment variables?
You can also inject environment variables to your gitlab-runner directly in the commandline, as the gitlab-runner exec docker --help states:
OPTIONS: ..
--env value Custom environment variables injected to build environment [$RUNNER_ENV] ..
Here is a small example how I use it in a script:
Change the declarations as needed:
declare jobname="your_jobname"
declare runnerdir="/path/to/your/repository"
Get the env file into a bash array.
[ -f "$runnerdir/env" ] \
&& declare -a envlines=($(cat "$runnerdir/env"))
declare -a envs=()
for env in "${envlines[#]}"; do
envs+=(--env "$env")
done
And finally pass it to the gitlab-runner.
[ -d "$runnerdir" ] && cd "$runnerdir" \
&& gitlab-runner exec docker "${envs[#]}" $jobname \
&& cd -
You can define environment variables to inject in the runner's config.toml file. See the advanced runner configuration documentation in the [[runners]] section.
There doesn't seem to be a way to specify environment variables in the GitLab UI just for a specific runner.
With GitLab 13.1 (June 2020), you now have:
Instance-level CI/CD variables
GitLab now supports instance-level variables.
With this ability to set global variables, you no longer need to manually enter the same credentials repeatedly for all your projects.
This MVC introduces access to this feature by API, and the next iteration of this feature will provide the ability to configure instance-level variables directly in the UI.
See Documentation and issue.
Consider using an external persistent secret storage service like Vault or Keywhiz
Disclaimer: I am not associated nor used any of the above services
I have added export MY_VAR="FOO" to gitlab-runner's .bashrc, and it works.
echo export MY_VAR=\"FOO\" >> /home/gitlab-runner/.bashrc
Check which type of executor do you use? (shell, kubernetes, docker-ssh, parallels...) I use shell executor.
Check what type of shell does gitlab-runner use? (How to determine the current shell I'm working on) And edit the proper rc file for that.
Check the Gitlab CI Runner user.
I suggest dump all environment variables for further debugging, by add env to the .gitlab-ci.yml's script:
#.gitlab-ci.yml
job:
script: env
Making changes in ~/.bash_profile NOT ~/.bashrc.
See my answer
You can easily setup Variables in the GitLab Settings:
Project-level variables can be added by going to your project's Settings > CI/CD, then finding the section called Variables.
To make sure your variables are only used in
See:
https://docs.gitlab.com/ee/ci/variables/#variables

Publishing an .apk into IBM Application Center from Application Center command-line tools

I'm trying to publish an .apk into my Application Center through console. I've followed this note but it doesn't work in my environment:
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/moving-production/distributing-mobile-applications-with-application-center/#cmdLineTools
If I type :
./acdeploytool.sh /home/miguel/Downloads/HelloWorldMyHelloAndroid.apk
I get this error message:
FWLAC0803E: Unable to connect:
Connection refused
Perhaps the server or context is wrongly specified.
File:/home/myUser/Downloads/HelloWorldMyHelloAndroid.apk
And if I try another way using this java command:
java com.ibm.appcenter.Upload -f http://localhost:9080 -c applicationcenter -u demo -p demo /home/myUser/Downloads/HelloWorldMyHelloAndroid.apk
I get this one:
Error: Could not find or load main class com.ibm.appcenter.Upload
I don't get any errors when I do this 'publish' operation directly in Application Center or through MobileFirst Studio.
Miguel, whether you use the script or the Java command, you need to specify the arguments to use. Please try the following:
./acdeploytool.sh -s http://localhost:9080 -c applicationcenter -u demo -p demo /home/miguel/Downloads/HelloWorldMyHelloAndroid.apk
I tried a similar command in my environment and was able to successfully deploy the apk to Application Center. If the command still does not work, make sure that the host/port that you are using are correct, and that the username and password are valid.
For the Java command that you executed, I see a few problems. First, the -cp argument needs to be specified in order to add the applicationcenterdeploytool.jar and json4j.jar files to the classpath. Next, the command shows "-f", but it should be "-s" to specify the server. Lastly, the path that was specified for the .apk is different than what you specified in the first command: myUser vs. miguel. So make sure that the correct path is used. If there are any further questions, let me know. Thanks.

How to define a variable in a Dockerfile?

In my Dockerfile, I would like to define variables that I can use later in the Dockerfile.
I am aware of the ENV instruction, but I do no want these variables to be environment variables.
Is there a way to declare variables at Dockerfile scope?
You can use ARG - see https://docs.docker.com/engine/reference/builder/#arg
The ARG instruction defines a variable that users can pass at
build-time to the builder with the docker build command using the
--build-arg <varname>=<value> flag. If a user specifies a build
argument that was not defined in the Dockerfile, the build outputs an
error.
Can be useful with COPY during build time (e.g. copying tag specific content like specific folders)
For example:
ARG MODEL_TO_COPY
COPY application ./application
COPY $MODEL_TO_COPY ./application/$MODEL_TO_COPY
While building the container:
docker build --build-arg MODEL_TO_COPY=model_name -t <container>:<model_name specific tag> .
To answer your question:
In my Dockerfile, I would like to define variables that I can use later in the Dockerfile.
You can define a variable with:
ARG myvalue=3
Spaces around the equal character are not allowed.
And use it later with:
RUN echo $myvalue > /test
To my knowledge, only ENV allows that, as mentioned in "Environment replacement"
Environment variables (declared with the ENV statement) can also be used in certain instructions as variables to be interpreted by the Dockerfile.
They have to be environment variables in order to be redeclared in each new containers created for each line of the Dockerfile by docker build.
In other words, those variables aren't interpreted directly in a Dockerfile, but in a container created for a Dockerfile line, hence the use of environment variable.
This day, I use both ARG (docker 1.10+, and docker build --build-arg var=value) and ENV.
Using ARG alone means your variable is visible at build time, not at runtime.
My Dockerfile usually has:
ARG var
ENV var=${var}
In your case, ARG is enough: I use it typically for setting http_proxy variable, that docker build needs for accessing internet at build time.
Christopher King adds in the comments:
Watch out!
The ARG variable is only in scope for the "stage that it is used" and needs to be redeclared for each stage.
He points out to Dockerfile / scope
An ARG variable definition comes into effect from the line on which it is defined in the Dockerfile not from the argument’s use on the command-line or elsewhere.
For example, consider this Dockerfile:
FROM busybox
USER ${user:-some_user}
ARG user
USER $user
# ...
A user builds this file by calling:
docker build --build-arg user=what_user .
The USER at line 2 evaluates to some_user as the user variable is defined on the subsequent line 3.
The USER at line 4 evaluates to what_user as user is defined and the what_user value was passed on the command line.
Prior to its definition by an ARG instruction, any use of a variable results in an empty string.
An ARG instruction goes out of scope at the end of the build stage where it was defined.
To use an arg in multiple stages, each stage must include the ARG instruction.
If the variable is re-used within the same RUN instruction, one could simply set a shell variable. I really like how they approached this with the official Ruby Dockerfile.
You can use ARG variable defaultValue and during the run command you can even update this value using --build-arg variable=value. To use these variables in the docker file you can refer them as $variable in run command.
Note: These variables would be available for Linux commands like RUN echo $variable and they wouldn't persist in the image.
Late to the party, but if you don't want to expose environment variables, I guess it's easier to do something like this:
RUN echo 1 > /tmp/__var_1
RUN echo `cat /tmp/__var_1`
RUN rm -f /tmp/__var_1
I ended up doing it because we host private npm packages in aws codeartifact:
RUN aws codeartifact get-authorization-token --output text > /tmp/codeartifact.token
RUN npm config set //company-123456.d.codeartifact.us-east-2.amazonaws.com/npm/internal/:_authToken=`cat /tmp/codeartifact.token`
RUN rm -f /tmp/codeartifact.token
And here ARG cannot work and i don't want to use ENV because i don't want to expose this token to anything else

use ffmpeg in vb.net service application

hi i want to write a vb.net application using ffmpeg . is there any possible way to run ffmpeg without putting ffmpeg.exe inside the application path or without any hardcoded path ?
Can Any hardcoded path of ffmpeg be used in windows service application ?
Process.Start("cmd.exe", "/k c:/ffmpeg/bin/ffmpeg.exe -i rtsp://198.168.1.40/cam -map 0:0 -map 0:1 -s -vcodec libx264 -g 60 -vb 500000 -strict experimental %03d.ts")
You can compile the FFmpeg libraries for Windows Runtime and link them.
There's a guide here:
https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT
Microsoft also released a FFmpegInterop library. This is useful for playback as it implements a MediaStreamSource.
If you don't include it with your application, wouldn't you necessarily have to provide a hard-coded path? I suppose you could add the path as an appSetting in your config file.
I include it as a resource in my assembly and reference it via the path from the application directory:
_ffmpeg = My.Application.Info.DirectoryPath & "\Resources\ffmpeg.exe"
It's similarly kicked off using Process.Start as you've noted, but by calling ffmpeg directly, rather than cmd.
Dim _FFmpegProcessPropertys As New ProcessStartInfo
_FFmpegProcessPropertys.FileName = _ffmpeg
_FFmpegProcessPropertys.Arguments = Params
_FFmpegProcessPropertys.UseShellExecute = False
_FFmpegProcessPropertys.RedirectStandardOutput = True
_FFmpegProcessPropertys.RedirectStandardError = True
_FFmpegProcessPropertys.CreateNoWindow = True
Dim FFmpegProcess = Process.Start(_FFmpegProcessPropertys)

Choose Device to run on for calabash-ios

How can I choose which device to run cucumber on with calabash-ios?
If you're looking to run calabash-ios on real devices you need to set a couple of environment variables
BUNDLE_ID=com.bundle.id.for.your.app DEVICE_ENDPOINT=http://192.168.1.111:37265 calabash-ios console your_app.ipa
this would open the calabash console. Using the command start_test_server_in_background will open the app (which has to already be installed on your device).
You need the bundle id set so calabash knows which app to open. You need the DEVICE_ENDPOINT set to the wifi address of the device so that calabash knows how to interact with the app once it's open.
If you want to run calabash on a simulator then fabb's answer should cover it.
Edited to fix the http endpoint as per comment from #jmoody
For running on a specific simulator, just set the DEVICE_TARGET env var when starting cucumber.
To find out which devices are available, you can execute instruments -s devices in terminal.
In my project, I run cucumber twice, once for iPad and once for iPhone. I do it the following way:
#!/bin/bash
set -x
cd ${0%/*}/..
: ${APP_BUNDLE_PATH:?"Need to set APP_BUNDLE_PATH"}
export DEBUG=1
SCREENSHOT_PATH_IPHONE=`pwd`/calabash_screenshots/iphone/
SCREENSHOT_PATH_IPAD=`pwd`/calabash_screenshots/ipad/
mkdir -p ${SCREENSHOT_PATH_IPHONE}
mkdir -p ${SCREENSHOT_PATH_IPAD}
export RESET_BETWEEN_SCENARIOS=1
SCREENSHOT_PATH=${SCREENSHOT_PATH_IPHONE} DEVICE_TARGET="iPhone 6 (8.1 Simulator)" bundle exec cucumber --tags #ios_phone -p ios
SCREENSHOT_PATH=${SCREENSHOT_PATH_IPAD} DEVICE_TARGET="iPad Retina (8.1 Simulator)" bundle exec cucumber --tags #ios_tablet -p ios
Note that this depends on a cucumber.yml and according tags #ios_phone and #ios_tablet being set in the feature files.