我们有一个 Jenkins CI 服务器,在 Ubuntu 上运行。我可以以 root 身份登录,但 jenkins 用户正在运行管道。作为管道的一部分,我想将图像推送到数字海洋注册表。我可以
我们有一个在 Ubuntu 上运行的 Jenkins CI 服务器。我可以以 身份登录 root
,但 jenkins
用户正在运行管道。作为管道的一部分,我想将图像推送到数字海洋注册表。
如果我以用户身份运行,我可以成功验证、登录和推送 root
,但我无法让它以 jenkins
用户身份工作(作为管道的一部分)。 sudo -u jenkins doctl auth init
例如,如果我调用,它想要写入 /root/.config
文件,这当然是不允许的,因为存在权限问题。
无论如何,我希望能够 doctl
连接到 jenkins
用户而不是 root
用户运行。要么安装 doctl
命令给 jenkins
用户,要么强制使用用户的配置文件/文件夹 jenkins
.
(您可能已经意识到,我并不是一名 Linux 专家。)
我该从哪里开始呢?我目前正在 Unity 上制作一款多人游戏,使用 Netcode 来处理 Gameobjects。我确保在每次添加后检查在线功能,以确保它
我该从哪里开始呢?我目前正在 Unity 上制作一款多人游戏,使用 Netcode 来处理 Gameobjects。我确保在每次添加后检查在线功能以确保它仍然有效,但在实现跟随每个玩家的摄像头后,它停止工作了。连接方式是通过三个按钮,主机、服务器和客户端,这些按钮是我通过代码设置的,是临时的。单击按钮后,主摄像头将被禁用,玩家会使用一个摄像头支架生成,该支架的子项是摄像头。此脚本由网络管理器保存。实现摄像头功能后,即使主机先进入,单击客户端按钮也不会让您进入游戏。我尝试使用 ParrelSync 克隆和构建对其进行测试,两者都与编辑器一起使用。最糟糕的是,我没有收到任何错误来引导我朝着正确的方向前进。在剥离代码并使用网络管理器按钮而不是我自己的按钮后,客户端确实加入了,但立即遇到了两个错误:
/Runtime/Core/NetworkUpdateLoop.cs:208)[Netcode] NetworkBehaviour 索引 3 超出了 Player(Clone)的界限。服务器和客户端之间的 NetworkBehaviours 必须相同且顺序相同。UnityEngine.Debug:LogError (object)Unity.Netcode.NetworkLog:LogError (string) (at ./Library/PackageCache/ [email protected] /Runtime/Logging/NetworkLog.cs:34)Unity.Netcode.NetworkObject:GetNetworkBehaviourAtOrderIndex (uint16) (at ./Library/PackageCache/ /Runtime/Core/NetworkObject.cs:1199)Unity.Netcode.NetworkVariableDeltaMessage:Handle (Unity.Netcode.NetworkContext&) (at ./Library/PackageCache/ [email protected ] /Runtime/Messaging/Messages/NetworkVariableDeltaMessage.cs:134)Unity.Netcode.NetworkMessageManager:ReceiveMessage (Unity.Netcode.FastBufferReader、Unity.Netcode.NetworkContext&、Unity.Netcode.NetworkMessageManager)(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/NetworkMessageManager.cs:564)Unity.Netcode.NetworkMessageManager:HandleMessage(Unity.Netcode.NetworkMessageHeader&、Unity.Netcode.FastBufferReader、ulong、single、int)(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/NetworkMessageManager.cs:432)Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue()(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/NetworkMessageManager.cs:458)Unity.Netcode.NetworkManager:NetworkUpdate(Unity.Netcode.NetworkUpdateStage)(位于 ./Library/PackageCache/ [email protected] /Runtime/Core/NetworkManager.cs:42)Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (位于 ./Library/PackageCache/ [email protected] /Runtime/Core/NetworkUpdateLoop.cs:185)Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:b__0_0 () (位于 ./Library/PackageCache/ [email protected]
和:
/Runtime/Core/NetworkUpdateLoop.cs:208)[Netcode] 收到不存在行为的网络变量增量消息。NetworkObjectId:2,NetworkBehaviourIndex:3UnityEngine.Debug:LogWarning(对象)Unity.Netcode.NetworkLog:LogWarning(字符串)(位于 ./Library/PackageCache/ [email protected] /Runtime/Logging/NetworkLog.cs:28)Unity.Netcode.NetworkVariableDeltaMessage:Handle(Unity.Netcode.NetworkContext&)(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/Messages/NetworkVariableDeltaMessage.cs:140)Unity.Netcode.NetworkMessageManager:ReceiveMessage (Unity.Netcode.FastBufferReader、Unity.Netcode.NetworkContext&、Unity.Netcode.NetworkMessageManager)(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/NetworkMessageManager.cs:564)Unity.Netcode.NetworkMessageManager:HandleMessage(Unity.Netcode.NetworkMessageHeader&、Unity.Netcode.FastBufferReader、ulong、single、int)(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/NetworkMessageManager.cs:432)Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue()(位于 ./Library/PackageCache/ [email protected] /Runtime/Messaging/NetworkMessageManager.cs:458)Unity.Netcode.NetworkManager:NetworkUpdate(Unity.Netcode.NetworkUpdateStage)(位于 ./Library/PackageCache/ [email protected] /Runtime/Core/NetworkManager.cs:42)Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (位于 ./Library/PackageCache/ [email protected] /Runtime/Core/NetworkUpdateLoop.cs:185)Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:b__0_0 () (位于 ./Library/PackageCache/ [email protected]
我还应该提到,虽然由于这些错误,客户端无法控制,但它仍然可以看到主机正在做什么,因为主机工作正常。 主编辑器和克隆尝试建立连接,编辑器是主机,克隆是客户端
现在我有一些线索,我需要你的帮助,因为我根本不明白这些错误是什么意思。这是代码,请记住,其中很多都是注释,我试图将代码简化到足够简单的状态,这样我就会在控制台中收到错误,或者它可以解决:网络按钮(完全禁用,附加到网络管理器):
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
using Unity.Netcode.Transports.UTP;
public class NetworkButtons : MonoBehaviour
{
public GameObject mainCam;
void OnGUI()
{
GUILayout.BeginArea(new Rect(10, 10, 300, 300));
if (!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
{
if (GUILayout.Button("Host")) {NetworkManager.Singleton.StartHost(); mainCam.SetActive(false);}
if (GUILayout.Button("Server")) {NetworkManager.Singleton.StartServer(); mainCam.SetActive(false);}
if (GUILayout.Button("Client")) {NetworkManager.Singleton.StartClient(); mainCam.SetActive(false);}
}
GUILayout.EndArea();
}
}
主播放器脚本(还有允许跳跃的代码,如果您需要请告诉我):
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
public class Player : NetworkBehaviour
{
private Rigidbody playerRb;
//public GameObject camHolderPrfb;
//public GameObject camHolder;
public float speed;
public float jumpForce;
public float gravityMod;
private bool onGround = true;
void Start()
{
//camHolder = Instantiate(camHolderPrfb, transform.position, Quaternion.identity);
playerRb = GetComponent<Rigidbody>();
Physics.gravity *= gravityMod;
}
void Update()
{
//Makes sure player can only control its character
if (!IsOwner) {return;}
//Calculates player movement
float forwInput = Input.GetAxis("Vertical");
float horzInput = Input.GetAxis("Horizontal");
Vector3 direction = /*camHolder.transform.forward*/Vector3.forward * forwInput + /*camHolder.transform.right*/Vector3.right * horzInput;
//Applies movement to player
if (direction.magnitude > 1) {direction.Normalize();}
playerRb.AddForce(direction * speed);
摄像机控制器(完全禁用,但也进行了注释,因为它依赖于主播放器脚本中的一个变量,我也对该变量进行了注释,并附加到播放器)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Unity.Netcode;
public class CamController : NetworkBehaviour
{
/*public float rotationSpeed;
public float lerpSpeed;
public GameObject camHolder;
private Camera playerCamComp;
private GameObject playerCam;
public Player PlayerScr;
void Start()
{
camHolder = PlayerScr.camHolder;
playerCamComp = camHolder.GetComponentInChildren<Camera>();
playerCam = playerCamComp.gameObject;
}
void FixedUpdate()
{
//Camera is rotatable with left and right keys
float camInput = Input.GetAxis("MoveCam");
camHolder.transform.Rotate(Vector3.up, camInput * Time.deltaTime * rotationSpeed);
//Camera moves and looks at the player
camHolder.transform.position = Vector3.Lerp(camHolder.transform.position, transform.position, lerpSpeed * Time.deltaTime);
playerCam.transform.LookAt(this.transform);
}*/
}
玩家网络(实际上并未使用,因为玩家除了位置和旋转之外没有其他需要同步的变量,对此我有网络变换,但以后会很有用):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
[System.Serializable]
public struct PlayerNetworkState : INetworkSerializable
{
public Vector3 Position;
public Vector3 Rotation;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref Position);
serializer.SerializeValue(ref Rotation);
}
}
public class PlayerNetwork : NetworkBehaviour
{
[SerializeField] private bool usingServerAuth;
private NetworkVariable<PlayerNetworkState> playerState;
private Rigidbody playerRb;
private void Awake()
{
playerRb = GetComponent<Rigidbody>();
var permission = usingServerAuth ? NetworkVariableWritePermission.Server : NetworkVariableWritePermission.Owner;
playerState = new NetworkVariable<PlayerNetworkState>(new PlayerNetworkState {Position = Vector3.zero, Rotation = Vector3.zero}, NetworkVariableReadPermission.Everyone, permission);
}
public override void OnNetworkSpawn()
{
if (!IsOwner) {
Destroy(transform.GetComponent<Player>());
Destroy(transform.GetComponent<CamController>());
}
}
private void Update()
{
if (IsOwner) TransmitState();
else ConsumeState();
}
#region Transmit State
private void TransmitState()
{
var state = new PlayerNetworkState
{
Position = playerRb.position,
Rotation = transform.rotation.eulerAngles
};
if (IsServer || !usingServerAuth)
{
playerState.Value = state;
}
else
{
TransmitStateServerRpc(state);
}
}
[ServerRpc(RequireOwnership = false)]
private void TransmitStateServerRpc(PlayerNetworkState state)
{
playerState.Value = state;
}
#endregion
#region Consume State
private void ConsumeState()
{
transform.position = playerState.Value.Position;
transform.rotation = Quaternion.Euler(playerState.Value.Rotation);
}
#endregion
}
我没有经验,这是我的第一个项目,所以它可能没有我想象的那么复杂,但我已经卡了将近一个星期了。如果你能解决这个问题,我将永远感激不尽!