I'm very new to Docker and I'm trying to get my Github repository setup with a docker when I push an update. However, when the github workfile script goes to push my code to Docker I get the following error.
Error: buildx failed with: error: failed to solve: failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount1164878607/target: lstat /var/lib/docker/tmp/buildkit-mount1164878607/target: no such file or directory
It appears Docker can't access the file I set for it in my Dockerfile yet no amount of tweaking with the code appears to fix it, aside for me completely removing the COPY tag which renders my Docker unrunnable, though it does send. I'm using maven compiler plugin along with maven shade plugin and have setup my pom.xml file accordingly.
Here is my Github WorkFile:
name: Docker
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Set up JDK
uses: actions/setup-java#v3.3.0
with:
java-version: 18
distribution: adopt
- name: Build with Maven
run: mvn clean package
- name: Login to DockerHub
uses: docker/login-action#v2.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action#v3.0.0
with:
push: true
tags: sudden/discordbot:latest
Here is my DockerFile:
FROM openjdk:11-jdk-slim
WORKDIR /tmp
COPY target/discordbot-1.0-SNAPSHOT-shaded.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]
What I've tried:
Copying another random file in my "src" directory.
Changing the name of my jar file and changing the path.
Changing my WORKDIR.
Changed the Docker's "context" and other tags in my Workfile.
Any help is appreciated. This might be a simple fix, but I've been stuck on it for a day despite my best efforts so asking here is a last resort. Thanks.
Make sure that you haven't excluded your target folders in your .dockerignore file.
That's what fixed it for me after several days of despairing search...
I was trying apply the concept of calling reusable workflows. I have a workflow for automated tests in repo1, and an actions workflow in repo2. The goal is to call on workflow/s from another repository and test execution/s should be successful.
However, I have encountered an error that says "The goal you specified requires a project to execute but there is no POM in this directory (D:\a\github-actions-course-test\github-actions-course-test). Please verify you invoked Maven from the correct directory. -> [Help 1]"
Please see images/details below. How do we solve this kind of issue/s? Sorry I'm new to github actions since this will be used in my project for the CI/CD. I may have missed something or probably this is not the right way of reusing workflows. I'm open for suggestions and ideas that might resolve this issue. Thank you so much!!
error:
The goal you specified requires a project to execute but there is no POM in this directory (D:\a\github-actions-course-test\github-actions-course-test). Please verify you invoked Maven from the correct directory. -> [Help 1]
repo 1 workflow
name: test_execution
on:
schedule:
- cron: "0 9,12,15,18,20,0,3,6 * 1-12 1-5"
push:
branches: [ master ]
workflow_call:
secrets:
SOME_SECRET:
required: true
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v3
- name: Set up JDK 11
uses: actions/setup-java#v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Maven and Test execution of Google Smoke Test
run: mvn clean test -DsuiteXmlFile="google.xml"
repo 2 workflow
name: Actions Workflow
on:
push:
branches: [main]
jobs:
run-github-actions:
runs-on: windows-latest
steps:
- name: List Files
run: |
ls
echo $GITHUB_SHA
echo $GITHUB_REPOSITORY
echo $GITHUB_WORKSPACE
echo "${{ github.token }}"
echo "for testing purposes"
automation-test:
needs: ["run-github-actions"]
uses: mirandaxyrus13/testautomationframework/.github/workflows/test_execution.yml#master
secrets:
SOME_SECRET: ${{ secrets.SOME_SECRET }}
I have a Spring Web Application in a DevOps repository, with a .yml that looks like this (as generated by the tool in the DevOps web client):
# Build your Java project and deploy it to Azure as a Linux web app
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- master
variables:
Version: '0.0.1'
# Azure Resource Manager connection created during pipeline creation
azureSubscription: '-snipped-'
# Web app name
webAppName: 'SlackCentralTestApp'
# Environment name
environmentName: 'SlackCentralTestApp'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: MavenPackageAndPublishArtifacts
displayName: Maven Package and Publish Artifacts
pool:
vmImage: $(vmImageName)
steps:
- task: Maven#3
displayName: 'Maven Package'
inputs:
mavenPomFile: 'pom.xml'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- task: CopyFiles#2
displayName: 'Copy Files to artifact staging directory'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: '**/target/SlackbotTest-$(Version)-SNAPSHOT.?(war|jar)'
TargetFolder: $(Build.ArtifactStagingDirectory)
- upload: $(Build.ArtifactStagingDirectory)
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeployLinuxWebApp
displayName: Deploy Linux Web App
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp#1
displayName: 'Azure Web App Deploy: SlackCentralTestApp'
inputs:
azureSubscription: 'Azure for Students (4998490e-1bc4-43fc-a370-80744706d1f5)'
appType: 'webAppLinux'
appName: 'SlackCentralTestApp'
package: '$(Pipeline.Workspace)/drop/target/SlackbotTest-$(Version)-SNAPSHOT.jar'
runtimeStack: 'JAVA|11-java11'
startUpCommand: 'java -jar $(Pipeline.Workspace)/drop/target/SlackbotTest-$(Version)-SNAPSHOT.jar'
The deployment process seems to be successful as seen in this screenshot, yet when I take a look at the server log, I sadly get greeted with the following error:
2020-04-14T09:03:55.658599508Z Initializing App Insights applicationinsights-agent-codeless-2.5.0.jar....
2020-04-14T09:03:55.669449167Z STARTUP_FILE=
2020-04-14T09:03:55.676322304Z STARTUP_COMMAND=java -jar /home/vsts/work/1/drop/target/SlackbotTest-0.0.1-SNAPSHOT.jar
2020-04-14T09:03:55.676350305Z No STARTUP_FILE available.
2020-04-14T09:03:55.676428905Z Running STARTUP_COMMAND: java -jar /home/vsts/work/1/drop/target/SlackbotTest-0.0.1-SNAPSHOT.jar
2020-04-14T09:03:55.681352232Z Error: Unable to access jarfile /home/vsts/work/1/drop/target/SlackbotTest-0.0.1-SNAPSHOT.jar
2020-04-14T09:03:55.694784805Z Finished running startup command 'java -jar /home/vsts/work/1/drop/target/SlackbotTest-0.0.1-SNAPSHOT.jar'. Exiting with exit code 1.
This would lead me to conclude that the path as given in the 'startUpCommand' property from the .yml file is incorrect, yet I have not been able to find what the correct path should be.
I have attempted the following:
Specify no directories, only the filename. Leads to the same result, sadly.
Use the 'find' command in Bash to find any .jars on the Web App, which tells me that there are none.
Manually building the application from the Web App does not seem to be an option either, as it's a Java 11 application and the java SE that seems to be included is version 1.8, regardless of the version I specify during the creation of the Web App resource in Azure.
I'm trying to provide a continuous deployment with Gradle and Heroku but for some reason, the deployment step is not running.
CircleCI Pipeline result
I've already updated the circle ci with the Heroku key.
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "build.gradle" }}
- v1-dependencies-
- run: gradle dependencies
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "build.gradle" }}
# run tests!
- run: gradle test
deployment:
staging:
branch: master
heroku:
appname: my-heroku-app
Could you guys help me, please? Is the deployment step in the right place?
You are using deployment configuration for CircleCI 1.0 but you are using CircleCI 2.0.
From the documentation for CircleCI 2.0:
The built-in Heroku integration through the CircleCI UI is not
implemented for CircleCI 2.0. However, it is possible to deploy to
Heroku manually.
To deploy on heroku with CircleCI 2.0, you need :
add environment variables HEROKU_LOGIN, HEROKU_API_KEY, HEROKU_APP_NAME to your CircleCI project settings https://circleci.com/gh/<account>/<project>/edit#env-vars
create a private ssh key without passphrase and add it to your CircleCI project settings https://circleci.com/gh/https://circleci.com/gh/<account>/<project>/edit#ssh for hostname git.heroku.com
add steps in the .circleci/config.yml file with the fingerprint of your ssh key
- run:
name: Setup Heroku
command: |
ssh-keyscan -H heroku.com >> ~/.ssh/known_hosts
cat > ~/.netrc << EOF
machine api.heroku.com
login $HEROKU_LOGIN
password $HEROKU_API_KEY
EOF
cat >> ~/.ssh/config << EOF
VerifyHostKeyDNS yes
StrictHostKeyChecking no
EOF
- add_ssh_keys:
fingerprints:
- "<SSH KEY fingerprint>"
- deploy:
name: "Deploy to Heroku"
command: git push --force git#heroku.com:$HEROKU_APP_NAME.git HEAD:refs/heads/master
I'm attempting to run the mvn release:prepare goal and it's hanging after the push. Any idea what I could be doing wrong?
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESSFUL
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 8 seconds
[INFO] [INFO] Finished at: Tue Jul 13 23:54:59 PDT 2010
[INFO] [INFO] Final Memory: 55M/294M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\Users\TAYLOR~1\AppData\Local\Temp\maven-scm-1932347225.commit pom.xml"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git push git#github.com:tleese22/my-app.git master:master"
[INFO] Working directory: C:\development\taylor\my-app
>>>> hangs here <<<<
Below is the SCM section of my pom.xml:
<scm>
<connection>scm:git:git://github.com/tleese22/my-app.git</connection>
<developerConnection>scm:git:git#github.com:tleese22/my-app.git</developerConnection>
<url>http://github.com/tleese22/my-app</url>
</scm>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
Below is my .git/config:
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
bare = false
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "origin"]
url = git#github.com:tleese22/my-app.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = git#github.com:tleese22/my-app.git
Here's the result of git show origin:
$ git remote show origin
Enter passphrase for key '/c/Users/Taylor Leese/.ssh/id_rsa':
* remote origin
Fetch URL: git#github.com:tleese22/my-app.git
Push URL: git#github.com:tleese22/my-app.git
HEAD branch: master
Remote branches:
gh-pages new (next fetch will store in remotes/origin)
master new (next fetch will store in remotes/origin)
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
$ git status
# On branch master
nothing to commit (working directory clean)
I have run into the same problem and I traced this to the fact that git is requiring a passphrase, but Maven has no way to specify an appropriate passphrase, so the process essentially hangs. Note that this problem is limited to Windows.
The solution is to run ssh-agent. This can be found in C:\Program Files (x86)\Git\bin\. After you run it, it outputs some environment variables that you need to set. For example:
SSH_AUTH_SOCK=/tmp/ssh-LhiYjP7924/agent.7924; export SSH_AUTH_SOCK;
SSH_AGENT_PID=2792; export SSH_AGENT_PID;
echo Agent pid 2792;
So, you need to place these in your environment:
C:\> set SSH_AUTH_SOCK=/tmp/ssh-LhiYjP7924/agent.7924
C:\> set SSH_AGENT_PID=2792
Then, you will need to add a passphrase for your particular key file. Generally, if you issued a command like git fetch origin master for your project, you will get a passphrase prompt like: Enter passphrase for key '/c/Users/Anthony Whitford/.ssh/id_rsa' -- that is the file that you need to register with the agent. So, the command is:
C:\> ssh-add "/c/Users/Anthony Whitford/.ssh/id_rsa"
It will prompt you for a passphrase, so enter it. You should see an Identity added message. Now, the agent knows the passphrase so that you will not be prompted to specify it anymore.
If you have multiple instances of command prompts, make sure that each command prompt has the appropriate SSH_AUTH_SOCK and SSH_AGENT_PID environment variables set. You can validate that this is working by running a command like ssh -v git#github.com and if you DO NOT get prompted for a passphrase, it is working!
Note that when you logoff, the ssh-agent will shut down and so when you log back in or restart your computer, you will need to repeat these steps. My understanding is that your passphrase is stored in memory, not persisted to disk, for security reasons.
The mvn release:prepare goal always runs in non-interactive mode, so you can't enter the ssh passphrase git is waiting for while pushing to the remote repository.
You can use an SSH agent to manage that, but if this problem only appears during the release process, there is another solution : preparing the release locally, and pushing the tag afterwards.
For this you have to use version 2.1+ of maven-release-plugin that comes with the pushChanges parameter.
mvn -DpushChanges=false release:prepare
By the way, your tag is created into your local GIT repository and you can then push it to the remote repository as usual, with a git push command.
This method is useful for Eclipse users because Eclipse comes with an embedded ssh-agent but this agent is not used by maven while performing a release:prepare, even when using eGit.
Considering the source of git builtin-push.c, that means that somehow, no remote are defined for the local Git repo used by the maven script.
static int do_push(const char *repo, int flags)
{
int i, errs;
struct remote *remote = remote_get(repo);
const char **url;
int url_nr;
if (!remote) {
if (repo)
die("bad repository '%s'", repo);
die("No destination configured to push to.");
}
As illustrated by this blog post, the maven config is not the all story.
~/foo/mikeci-archetype-springmvc-webapp$ git remote add origin git#github.com:amleggett/mikeci-archetype-springmvc-webapp.git
A remote add is still required, before specifying the maven scm parameters:
Updating the POM
For Maven to function effectively, you should always ensure that you include project VCS information in your POM file.
Now that we’ve added the archetype to a Git repository we can include the appropriate <scm> configuration:
<scm>
<connection>
scm:git:ssh://github.com/amleggett/${artifactId}.git
</connection>
<developerConnection>
scm:git:ssh://git#github.com/amleggett/${artifactId}.git
</developerConnection>
<url>
http://github.com/amleggett/${artifactId}
</url>
</scm>
The same blog post adds:
It’s important to understand the meaning of each of the child elements of <scm>.
The <connection> element defines a read-only url and
the <developerConnection> element a read+write url.
For both of these elements the url must adhere to the following convention:
scm:<scm implementation>:<scm implementation-specific path>
Finally, the <url> element content should point to a browsable location and for me this is the GitHub repository home page. Note that in all cases, I’m using an interpolated value which is my project artifactId.
One handy tip is that you can verify this configuration by using the maven-scm-plugin.
This plugin offers ‘vendor’ independent access to common VCS commands by offering a set of command mappings for the configured VCS. The validate goal should confirm all is well:
~/foo/mikeci-archetype-springmvc-webapp$ mvn scm:validate
[INFO] Preparing scm:validate
[INFO] No goals needed for project - skipping
[INFO] [scm:validate {execution: default-cli}]
[INFO] connectionUrl scm connection string is valid.
[INFO] project.scm.connection scm connection string is valid.
[INFO] project.scm.developerConnection scm connection string is valid.
[INFO] --------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
These are the exact sequence of commands I followed to get rid of this error
C:\Program Files (x86)\Git\bin>bash
bash-3.1$ eval 'ssh-agent -s'
SSH_AUTH_SOCK=/tmp/ssh-ZARFN11804/agent.11804; export SSH_AUTH_SOCK;
SSH_AGENT_PID=10284; export SSH_AGENT_PID;
echo Agent pid 10284;
bash-3.1$ exec ssh-agent bash
bash-3.1$ ssh-add "/c/Users/idntus/.ssh/id_rsa"
Enter passphrase for /c/Users/idntus/.ssh/id_rsa:
Identity added: /c/Users/idntus/.ssh/id_rsa (/c/Users/idntus/.ssh/id_rsa)
bash-3.1$ mvn release:prepare release:perform
The only thing which worked for me was specifying GIT user name and password as maven parameters:
mvn -Dusername=jenkins -Dpassword=******** release:prepare release:perform
To hide password in Jenkins output console I installed and configured Mask Passwords Plugin.
Yet another reason it could hang is if github.com isn't in the known_hosts file. SSH will therefore hang waiting for the user to accept authenticity of the host.
To add github.com to your known hosts just do a quick SSH to it: ssh github.com. The SSH client will then ask you to confirm the authenticity of the host. Type "Yes" and it'll say that its permanently added github.com to your list of known hosts.
I had faced the same problem, I had tried many ways but got to resolved it with below steps:
1. you need check git origin
2. update your pom.xml,find scm section,
change github ssh address the `:` to '/'
before
<scm>
<connection>scm:git:ssh://git#github.com:xxx/xxxin.git</connection>
<developerConnection>scm:git:ssh://git#github.com:xxx/xxxin.git</developerConnection>
<url>https://github.com/xxx/jenkins-xxx-plugin</url>
<tag>HEAD</tag>
</scm>
then
<scm>
<connection>scm:git:ssh://git#github.com/xxx/xxxin.git</connection>
<developerConnection>scm:git:ssh://git#github.com/xxx/xxxin.git</developerConnection>
<url>https://github.com/xxx/jenkins-xxx-plugin</url>
<tag>HEAD</tag>
</scm>
3. set ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>maven.jenkins-ci.org</id> <!-- For parent 1.397 or newer; before this use id java.net-m2-repository -->
<username>your jenkins username</username>
<password>your jenkins password</password>
</server>
</servers>
4. then commit & push your changes
5. run mvn release:prepare release:perform
I had the same issue.
I tried all the above solutions and still it did not work.
That was because I was still doing one thing wrong: for the ssh commands I used git bash while for the maven command I used the command prompt. And there not all the git commands were available.
After adding the complete git bin folder to the PATH variable everything worked for me.