Drone.io auto_tag with branch name - drone.io

Using the drone docker plugin in order to create my cloud images, I would like to simplify the workflow by having drone automatically tagging my images depending of the git branch name I'm working with.
I saw a auto_tag but unfortunately it always tag my images as "latest".
###
# Tag deployment
# Docker image
###
push-tag-news:
image: plugins/docker
registry: docker.domain.com:5000
secrets: [docker_username, docker_password]
repo: docker.domain.com:5000/devs/news
auto_tag: true # Or how to specify the current branch for the tags: option?
when:
exclude: [master, dev]
has anyone tried to do something similar?
I'm using drone 0.8

The auto_tag uses the repository/git tags seems to me you are looking to set custom docker image tags.
You can use any of these variables http://docs.drone.io/environment-reference/
Try using DRONE_COMMIT_BRANCH
build-docker-image:
image: plugins/docker
repo: myname/myrepo
secrets: [ docker_username, docker_password ]
tags:
- ${DRONE_COMMIT_BRANCH}
- latest

Related

when refreshing, it returning The resource you are looking for has been removed, had its name changed, or is temporarily unavailable

I deployed a Nuxt 3 website as a classic SPA since I don't need SSR for my project. Used nuxt generate and deployed the contents from .output/public/ in Azure static web app. It is successfully running now, but when I'm accessing pages with dynamic routes like user/[id] and hit refresh the page, I'm getting this message:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
nuxt.config.ts
export default defineNuxtConfig({
ssr: false,
});
I'm just really new on Nuxt and in Vue world will appreciate any help guys.
I have followed the MSDoc and able to run the Nuxt JS app without any issues.
Make sure you have followed the same steps as below.
Navigate to the GitHub and create a new repository from nuxt-3-starter.
New repo with code will be generated.
In Azure Portal, create a new Static Web App.
Select the GitHub and provide the Repository and branch details as shown below.
We can also check the Workflow file.
My Workflow:
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout#v2
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy#v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PLANT_0E617661E }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: ".output/server"
output_location: ".output/public" # Built app content directory
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy#v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PLANT_0E617661E }}
action: "close"
Make sure the build and deployment are successful. We can check it in GitHub Repository => Actions.
Click on the Workflow file, you can see the Jobs Status.
OutPut:
With dynamic routes - user/[id]
Please Check the code in my GitHub Repository.

How to configure renovate to switch from gitlab-release to git-tags

My goal is to update all includes in my gitlab-ci.yml files. By default without any custom configuration renovate create MR with an include update based on gitlab-release.
But today, I have some includes only based on tag and there isn't any release associated to this tag. I looking for a solution to update also these includes.
To explain, if I have a release for myprojet named 1.2.3 and tag 1.2 and 1
include:
# Bash template
- project: "myproject"
ref: "1.2.2"
file: "templates/gitlab-ci.yml"
renovate detects there is a new release on 1.2.3 - It's OK
If I have :
include:
# Bash template
- project: "myproject"
ref: "1.1"
file: "templates/gitlab-ci.yml"
renovate don't detect tag named 1.2 for myproject
have you tried regex managers?
here's an example, change it for your needs:
"regexManagers": [
{
"fileMatch": ["(^|/)\\.?gitlab-ci\\.yml$"],
"matchStringsStrategy": "combination",
"matchStrings": [
"\\s\\sCHART_SOURCES_URL: \"(?<depName>.*?)\"\n",
"\\s\\sCHART_SOURCES_VERSION: \"(?<currentValue>.*?)\"\n"
],
"datasourceTemplate": "git-tags"
}
],
i believe you could also set enabled=false for the actual gitlab-ci manager using matchManagers in package rules

Unexpected symbol: ‘2e4ce68d4e3feec97e992821e6391166943f4d49’

I tried to built github .yml file but I’m getting error like
|GitHub Actions/ Main Workflow
Invalid workflow file
The workflow is not valid. .github/workflows/build.yml (Line: 22, Col: 22): Unexpected symbol: '<hash_value>'. Located at position 9 within expression: secrets.<hash_value>|
CODE
on:
Trigger analysis when pushing in master or pull requests, and when creating
a pull request.
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
name: Main Workflow
jobs:
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action#v1.3
env:
GITHUB_TOKEN: {{ secrets.<hash_value>}} SONAR_TOKEN: {{ secrets.<hash_value>}}
AND
#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here
#----- Default SonarQube server
sonar.host.url=https://sonarcloud.io/
#----- Default source code encoding
#sonar.sourceEncoding=UTF-8
sonar.organization=blah blah
sonar.projectKey=blah blah
— optional properties —
defaults to project key
sonar.projectName=Toolsdemo
defaults to ‘not provided’
sonar.projectVersion=1.0
Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=https://github.com/abcd/xyz
Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
Please help . I need to test my code very fast .

Dynamically setting docker image tag from semver when using docker-image-resource in concourse

I have the following semver setup:
- name: version
type: semver
source:
driver: gcs
bucket: my-ci
json_key: ((my.serviceaccount))
key: version/version.txt
initial_version: 0.0.0
In my publishjob, I have the following:
name: publish
serial_groups: [version]
plan:
- get: version
passed: [build]
trigger: true
So, basically the publish job is triggered after build job is passed (version updated)
Now, in the publish job I am creating a docker image and pushing it to gcr.
- put: my-gcr
params:
additional_tags: my/ci/tags
build: mycode
get_params: {skip_download: true}
Here, the image is correctly tagged based on the values in the tags file. However, I want to set these values dynamically based on the current version which can be retreived following this:
https://concoursetutorial.com/miscellaneous/versions-and-buildnumbers/#display-version
How can I use this version number to tag my docker image?
I solved it using the following code:
- put: artifacts
params:
additional_tags: version/number
build: mycode
get_params: {skip_download: true}

How do I use a node selector with a build config in openshift?

I am running a large world spanning openshift cluster. When I run a build from a BuildConfig it will randomly assign the build to any node in the entire cluster. This is problematic as many regions have higher latency which dramatically slows down build times and image uploads. I can't find any information in the documentation on using node selector tags at this level. I have tried adding openshift.io/node-selector: dc=mex01 to the annotations as it is done with project level node-selectors to no avail. Any help would be great. Thanks!
Project node selectors are the only way to control where builds happen at the present time.
Since this is the Question that shows up first on Google:
This is now possible (since 1.3 apparently): https://docs.openshift.org/latest/dev_guide/builds/advanced_build_operations.html#dev-guide-assigning-builds-to-nodes
To elaborate a bit on mhutter's answer, here are example yaml fragments using node selectors:
a BuildConfig:
apiVersion: "v1"
kind: "BuildConfig"
metadata:
name: "sample-build"
spec:
nodeSelector:
canbuild: yes
and a Node:
apiVersion: v1
kind: Node
metadata:
creationTimestamp: null
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/hostname: mybestnodeever
canbuild: yes
Since OCPv3.6 there are the taints and tolerations, which can be applied to nodes and pods, but I haven't yet found any docs on applying tolerations to the build configs (or on whether they propagate to the builder pods).
https://docs.openshift.com/container-